61.8k views
3 votes
Refer to the following code

maximum = 0
for i in range (10):
n = int(input("Enter a number: "))
if (n >= 0 and n > maximum):
maximum = n
print(maximum)
How many variables are in the program
A) 1
B) 2
C) 3
D) 4

2 Answers

6 votes

Final answer:

The Python program provided uses 3 variables in total: 'maximum', 'i', and 'n'. Thus, the correct answer to the question of how many variables are in the program is C) 3.

Step-by-step explanation:

The code in question is a simple Python program that finds the maximum positive number entered by the user. When we count the variables, we can see the following are being used:

  • maximum - to store the current maximum number,
  • i - as the loop variable in the range function,
  • n - to store the number inputted by the user.

In total, there are 3 variables in the program. Therefore, the correct answer is C) 3.

User Kuntal Ghosh
by
9.1k points
4 votes
the answer is 3. hope this helps you out
User Bryant
by
7.9k points

No related questions found