# Doubt in an exercise with While condition

2

Hi, I've been doing exercises with the While condition, but I still have trouble understanding how the exercise works. It consists of entering 10 notes and saying the notes over 7 and under, I have guided myself with other exercises and I have managed to get it out ...

``````x=1
conta1=0
conta2=0
while x <= 10:
notas= int(input("Introduce las notas"))
if notas >= 7:
conta1= conta1+1
else:
conta2=conta2+1
x=x+1
print("Las notas mayores a 7 son",conta1)
print("Las notas menores a 7 son",conta2)
``````

My question is that does the sentence conta1 = conta1 + 1? < - Is this where the notes are stored? Why do we have to enter x = x + 1 at the end? Why is it necessary to initialize conta1 and conta2 from 0?

Thank you,

asked by Rebc3sp 22.04.2018 в 15:00
source

1
``````x=1
conta1=0
conta2=0
while x <= 10:
notas= int(input("Introduce las notas"))
if notas >= 7:
conta1= conta1+1
else:
conta2=conta2+1
x=x+1
print("Las notas mayores a 7 son",conta1)
print("Las notas menores a 7 son",conta2)
``````

I commented that the x = x + 1, helps the while cycle is not done   infinite because since each iteration increases its value by one and   finish the program execution when x is less than or equal to 10, is   say that you will be able to enter a maximum of 10 qualification notes

The use of conta1, is the variable that will store the total of the   notes that you entered and that will be used to display the message   notes greater than 7 are :, conta1; as you observe there are 2 possible messages, whether the notes are greater than 7 or if they are less than 7, then the variable conta1 saves the number of notes when you entered more than 7