0% found this document useful (0 votes)
10 views8 pages

Python Questions On Flow of Control-Week 2

The document contains Python programs that demonstrate various functionalities such as checking if a person can vote based on age, determining student grades based on scores, identifying if a number is positive, negative, or zero, printing the first 10 natural numbers, even numbers, odd numbers, and calculating the sum of the first 10 natural numbers. Each program includes user input and conditional statements to achieve the desired output. The examples illustrate basic programming concepts and control flow in Python.

Uploaded by

d2kzgpntj5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views8 pages

Python Questions On Flow of Control-Week 2

The document contains Python programs that demonstrate various functionalities such as checking if a person can vote based on age, determining student grades based on scores, identifying if a number is positive, negative, or zero, printing the first 10 natural numbers, even numbers, odd numbers, and calculating the sum of the first 10 natural numbers. Each program includes user input and conditional statements to achieve the desired output. The examples illustrate basic programming concepts and control flow in Python.

Uploaded by

d2kzgpntj5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
You are on page 1/ 8

Python

Questions
Q1.Program to check if a person
can vote

Conditio ●
Display message
n

Age>=18 ●
Eligible for voting

age=int(input("Enter the age of the person"))


if age>=18:
print("Eligible for Voting")

Other question: Program to check if a person can vote or not


using if else statement.
Q2. To check the grade of a student
score = float(input("Enter the student's score: "))
if score >= 90:
print("The student's grade is:A")
elif score >= 80:
print("The student's Grade is:B")
elif score >= 70:
print("The student's Grade is:C")
elif score >= 60:
print("The student's Grade is:D")
elif score >= 50:
print("The student's Grade is:E")
else:
print("The student's Grade is:F")
Q3. Input a number and check if the number
is positive, negative or zero and display an
appropriate message
number=int(input("enter the number"))
if number > 0:
print('Positive number')
elif number < 0:
print('Negative number')
else:
print('Zero')
print('This statement is always executed')
Q4. To print the first 10 natural
numbers

for i in range(1, 11):


print(i)
Q5. To print first 10 even numbers

for i in range(1, 21):


if i % 2 == 0:
print("even number:",
i)
Q6. To print odd numbers from 1 to n

n = int(input("Enter a positive integer n: "))


for i in range(1, n + 1):
if i % 2 != 0:
print(i)
Q7. To print sum of first 10 natural
numbers
s=0
for i in range(1, 11):
s=s+i
print("The sum of the first 10 natural numbers
is:",s)

You might also like