- 3

How do I do this?

Write a program in python which asks for the user to input 10 numbers and then outputs the largest number, smallest number and the amount of numbers dividable by 3. -Can someone explain how to solve this?

27th May 2021, 10:29 AM
Bartol Pavušek
Bartol Pavušek - avatar
2 Antworten
+ 3
Make three variables , max, min, count. store the first input in max and min and for count check if it's divisible by 3,if yes increment it . Now run a for loop of range 9, ask for user input inside it . for i in range(9) : num=int(input()) After that check for max, if num>max: max=num for min , if num<min: min=num for count, if num%3==0 or if (not num%3): count+=1
27th May 2021, 12:07 PM
Abhay - avatar
+ 2
better to not use variable name wich overide builtin functions ^^ max() and min() could help you... first store user inputed numbers in a list, while you count how many are divisible by three (num%3==0). then you could output the result of max(nums_list), min(nums_list) and count_of_divisible_by_3
27th May 2021, 12:12 PM
visph - avatar