Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. """
  2. Four random transactions
  3. Author : Daniel Herrmann
  4. """
  5. initial_balance = 768
  6. transaction_min = 15
  7. transaction_max = 502
  8.  
  9. import math
  10. import random
  11.  
  12.  
  13. allowed_values = list(range(-1, 1+1))
  14. allowed_values.remove(0)
  15. transaction_type = random.choice(allowed_values)
  16. transaction_type_2 = random.choice(allowed_values)
  17. transaction_type_3 = random.choice(allowed_values)
  18. transaction_type_4 = random.choice(allowed_values)
  19.  
  20.  
  21.  
  22. transaction_1 = random.randint(15,502)*transaction_type
  23. outcome_1 = initial_balance + transaction_1
  24.  
  25. transaction_2 = random.randint(15,502)*transaction_type_2
  26. outcome_2 = outcome_1 + transaction_2
  27.  
  28. transaction_3 = random.randint(15,502)*transaction_type_3
  29. outcome_3 = outcome_2 + transaction_3
  30.  
  31. transaction_4 = random.randint(15,502)*transaction_type_4
  32. outcome_4 = outcome_3 + transaction_4
  33.  
  34. sum_of_transactions = transaction_1 + transaction_2 + transaction_3 + transaction_4
  35.  
  36. print("Initial bank balance: $", initial_balance)
  37. print("==============================")
  38. print("1:", transaction_1, outcome_1)
  39. print("2:", transaction_2, outcome_2)
  40. print("3:", transaction_3, outcome_3)
  41. print("4:", transaction_4, outcome_4)
  42. print("==============================")
  43. print("Final bank balange: $", outcome_4)
  44. print("Sum of transactions:", sum_of_transactions)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement