Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1)

def main():
amount = int(input("How many numbers will you input?"))
sum = 0.0
x = "yessa"
for x in range(amount):
x = float(input("Input your numbers:"))
sum = x + sum
x = print("The following is the average of your", amount, "numbers:")
print("The average is:", sum / amount)

main()

2)
def main():
counter = 0
sum = 0.0
x = "yessa"
while x == "yessa":
x = float(input("Input your numbers:"))
sum = x + sum
counter += 1
x = input("If you have another number, write yessa and if not, write
dunno")
print("The average is:", sum / counter)

main()

3)
def main():
words = []
y = "yessa"
while y == "yessa":
x = input("What is your name?")
y = input("If you have another name, write yessa and if not, press 1")
words.append(x)

print("The names you mentioned are the following:", words)

main()
4)
def main():
counter = 0
sum = 0.0
x = "yessa"
while x == "yessa":
name = input("What is your name?")
for x in range(3):
x = float(input("Input your scores:"))
sum = x + sum
counter + = 1
x = input("If you have another student, write yessa and if not, press
1.")
print("The average grade for", name, "is:", sum / 3)

main()

5)
def main():
counter = 0
sum = 0.0
name = (input("What is your name?"))
while True:
try:
x = float(input("Input your score:"))
sum +=x
counter += 1
except ValueError:
print("This input is not supported by this program.")
z = input("If you have more scores, write yes. If not, press 1.")
if z == "1":
break
average = sum / counter
print("The average grade of", name, "is:", average)

main()

You might also like