Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 3

11/7/23, 3:49 PM 5th_Class.

ipynb - Colaboratory

"""
Q1. Write a program that takes a student's score as input and assigns a
letter grade (A, B, C, D, or F) based on the following criteria:
A: 90-100
B: 80-89
C: 70-79
D: 60-69
F: 0-59

"""

score = int(input("Enter the student's score: "))


if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
elif score >= 70:
print("Grade: C")
elif score >= 60:
print("Grade: D")
else:
print("Grade:
F")

Enter the student's score: 45


Grade: F

# Q2. Write a program that checks if a given number is odd or even.

num = int(input("Enter a number: "))


if num % 2 == 0:
print("Even number")
else:
print("Odd
number")
https://colab.research.google.com/drive/18X2Tyd-8ozjAsR1Kz7mdm40dSiwaOsvg#scrollTo=b53tU9p8OksP&printMode=true 1/3
11/7/23, 3:49 PM 5th_Class.ipynb - Colaboratory

Enter a number: 56
Even number

# Q3. Print out the positive, negative and zero number.

number = int(input("Enter any number: "))


if number > 0:
print("Positive")
elif number < 0:
print("Negative")
else:
print("Zero")

Enter any number: 5


Positive

# Q4. Check voting eligibility.

age = 17
if age >= 18:
print("You are eligible to vote")
else:
print("You are not eligible
to vote")

You are not eligible to vote

# Q5. Determine the Largest of Three Numbers:

a, b, c = 12, 8, 17
if a >= b and a >= c:
https://colab.research.google.com/drive/18X2Tyd-8ozjAsR1Kz7mdm40dSiwaOsvg#scrollTo=b53tU9p8OksP&printMode=true 2/3
11/7/23, 3:49 PM 5th_Class.ipynb - Colaboratory
print("a is the largest")
elif b >= a and b >= c:
print("b is the largest")
else:
print("c is the
largest")

c is the largest

https://colab.research.google.com/drive/18X2Tyd-8ozjAsR1Kz7mdm40dSiwaOsvg#scrollTo=b53tU9p8OksP&printMode=true 3/3

You might also like