Answer to Question #203578 in Electrical Engineering for sarah

Question #203578

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))




1
Expert's answer
2021-06-07T05:47:09-0400

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.')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS