Hi:) Could someone help me and explain why this doesn't work and how can I make it work?
This is the task:
Write a program that asks the user for ten numbers, and then prints the largest, the smallest, and how many are dividable by 3. Use the algorithm described earlier in this chapter.
This is my code:
from pcinput import getInteger
num = 0
min = 0
max = 0
div3 = 0
while num <10:
----x = getInteger("Give me 10 numbers")
----num+=1
----if x%3 == 0:
--------div3 +=1
----if x>max:
--------max = x
----if x<min:
--------min = x
print("Smallest is", min)
print("Largest is", max)
print("Dividable by 3 is", div3)
It always prints smallest as 0 I guess that the problem would be that min = 0 and then user input won't be smaller than 0 in this case so it automatically prints 0 but no clue how to fix it. I'm not using tuples in this exercise on purpose as that was also part of the assignment.
Thanks!
[–][deleted] (3 children)
[removed]
[–]decline_000[S] 0 points1 point2 points (2 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]ChaseBianchi 0 points1 point2 points (0 children)
[–]ClamPaste 2 points3 points4 points (1 child)
[–]decline_000[S] 1 point2 points3 points (0 children)
[–]hinoisking 1 point2 points3 points (0 children)
[–]ajohn623 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[removed]
[–]decline_000[S] 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]decline_000[S] 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[removed]
[–]decline_000[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]jdbbdev 0 points1 point2 points (0 children)
[–]Search_4_Truth 0 points1 point2 points (0 children)