Skip to content

Commit 7e0f715

Browse files
committed
TR updates, first round
1 parent 989866d commit 7e0f715

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

python-code-quality/input_v1.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
user_input = input("Enter number: ")
2-
result = int(user_input) * 2
3-
print(f"Duplicate: {result}")
1+
user_input = "Amount to withdraw? "
2+
amount = int(input(user_input))
3+
available_balance = 1000
4+
print(f"Here are your {amount:.2f}USD")
5+
print(f"Your available balance is {available_balance - amount:.2f}USD")

python-code-quality/input_v2.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
user_input = input("Enter number: ")
2-
try:
3-
number = int(user_input)
4-
except ValueError:
5-
print("Error: invalid input")
1+
user_input = "Amount to withdraw? "
2+
amount = int(input(user_input))
3+
available_balance = 1000
4+
if amount > available_balance:
5+
print("Insufficient funds")
6+
amount = 0
67
else:
7-
print(f"Duplicate: {number * 2}")
8+
print(f"Here are your {amount:.2f}USD")
9+
10+
print(f"Your available balance is {available_balance - amount:.2f}USD")

0 commit comments

Comments
 (0)