Correct the mistakes in the following python programme then save the corrected code in the Word file by copying and pasting it.
a = input(("Type a number here: ")
x = float(a)
b = input("Type another number here: "))
y = float(b)
if a > b:
print("the number " + str(x)+ " is bigger than the number" + str(y))
elseif a == b:
print("the numbers are equal")
else:
print("the number " +str(x)+ " is smaller than the number " + str(b))
File "<string>", line 2
x = float(a)
^
SyntaxError: invalid syntax
# Get input
cents = int(input('How many cents do you need to give out? '))
# Do computations
quarters = cents // 25
cents = cents % 25
dimes = cents // 10
cents = cents % 10
nickels = cents // 5
pennies = cents % 5
# Print results
print('Your change is')
if quarters > 1:
print(str(quarters)+' quarters')
elif quarters == 1:
print('1 quarter')
if dimes > 1:
print(str(dimes)+' dimes')
elif dimes == 1:
print('1 dime')
if nickels == 1:
print('1 nickel')
if pennies > 1:
print(str(pennies)+' pennies.')
elif pennies == 1:
print('1 penny.')
Comments
Leave a comment