Python 7 Levels, L3, Unit 19, While Loop

Powered By EmbedPress

Exercise 1:

password = input("Please input password")
while password != "abc":
    print("Wrong password.")
    password = input("Please input one more time:")
print("Password is good")

Exercise 2:

i = 1
sum = 0
while i <= 100:
    sum = sum + i
    i = i + 1
print("1+2+3+4+5+…+100=",sum)

Homework:

number = int(input("What number multiplication table would you like to see?"))
i = 1;
while i < 10:
    print(number,"x",i,"=",number*i)
    i = i + 1

dahan1999

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts