Exercise 1:
number = int(input("Please input how many students in the class:"))
i = 0;
sum = 0;
while i < number:
score = int(input("Please input the score of "+str(i+1)+" student:"))
sum = sum + score
i = i + 1
print("The average score of the class is: ",sum/number)
Exercise 2:
year = 2017
student = 50000
while student < 200000:
student = student+student*0.2
year = year + 1
print("At 20% increase rate, in ",year," there will be 200,000 students.")
Exercise 3:
n = int(input("Please input a positive integer:"))
sum = 0
i = 0
while i <= n:
sum = sum + i
i = i + 1
print("1+..+",n,"sum is: ",sum)
Homework:
number1 = int(input("What number multiplication table would you like to check?"))
number2 = int(input("What is the max number it multiplies?"))
i = 1
while i <= number2:
print(number1,"x",i,"=",number1*i)
i = i + 1
[…] Shoot I| |____Unit 18 Rock Paper Scissor Shoot II|____Python Level 3| |____Unit 19 while loop| |____Unit 20 while loop practice| |____Unit 21 guess number game| |____Unit 22 for loop| |____Unit 23 break and continue| |____Unit […]