Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Four random transactions
- Author : Daniel Herrmann
- """
- initial_balance = 768
- transaction_min = 15
- transaction_max = 502
- import math
- import random
- allowed_values = list(range(-1, 1+1))
- allowed_values.remove(0)
- transaction_type = random.choice(allowed_values)
- transaction_type_2 = random.choice(allowed_values)
- transaction_type_3 = random.choice(allowed_values)
- transaction_type_4 = random.choice(allowed_values)
- transaction_1 = random.randint(15,502)*transaction_type
- outcome_1 = initial_balance + transaction_1
- transaction_2 = random.randint(15,502)*transaction_type_2
- outcome_2 = outcome_1 + transaction_2
- transaction_3 = random.randint(15,502)*transaction_type_3
- outcome_3 = outcome_2 + transaction_3
- transaction_4 = random.randint(15,502)*transaction_type_4
- outcome_4 = outcome_3 + transaction_4
- sum_of_transactions = transaction_1 + transaction_2 + transaction_3 + transaction_4
- print("Initial bank balance: $", initial_balance)
- print("==============================")
- print("1:", transaction_1, outcome_1)
- print("2:", transaction_2, outcome_2)
- print("3:", transaction_3, outcome_3)
- print("4:", transaction_4, outcome_4)
- print("==============================")
- print("Final bank balange: $", outcome_4)
- print("Sum of transactions:", sum_of_transactions)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement