Conditional Statements
Conditional Statements
7. Write a program which takes any date as input and display next
date of the calendar e.g. I/P: day=20 month=9 year=2005 O/P:
day=21 month=9 year 2005
Code
d = int(input("Enter day: "))
m = int(input("Enter month: "))
y = int(input("Enter year: "))
if (y % 4 == 0 and y % 100 != 0) or (y % 400 == 0):
leap_year = True
else:
leap_year = False
if m in [1, 3, 5, 7, 8, 10, 12]:
days_in_month = 31
elif m in [4, 6, 9, 11]:
days_in_month = 30
elif m == 2:
days_in_month = 29 if leap_year else 28
if d < days_in_month:
d += 1
else:
d=1
if m < 12:
m += 1
else:
m=1
y += 1
print(f"Next Date: {d}/{m}/{y}")
output…
8. Print the grade sheet of a student for the given range of cgpa.
Scan marks of five subjects and calculate the percentage.
CGPA=percentage/10 CGPA range: 0 to 3.4 -> F 3.5 to 5.0->C+
5.1 to 6->B 6.1 to 7-> B+ 7.1 to 8-> A 8.1 to 9->A+ 9.1 to 10-> O
(Outstanding) Sample Gradesheet Name: Rohit Sharma Roll
Number: R17234512 SAPID: 50005673 Sem: 1 Course: B.Tech.
CSE AI&ML Subject name: Marks PDS: 70 Python: 80 Chemistry:
90 English: 60 Physics: 50 Percentage: 70% CGPA:7.0 Grade:
Code
name = input("Enter the student's name: ")
roll_number = input("Enter the roll number: ")
sapid = input("Enter the SAPID: ")
semester = input("Enter the semester: ")
course = input("Enter the course: ")
cgpa = percentage / 10
print("\nSample Gradesheet")
print(f"Name: {name}")
print(f"Roll Number: {roll_number} SAPID: {sapid}")
print(f"Sem: {semester} Course: {course}")
print("Subject Marks:")
print(f"Subject 1: {subject1}")
print(f"Subject 2: {subject2}")
print(f"Subject 3: {subject3}")
print(f"Subject 4: {subject4}")
print(f"Subject 5: {subject5}")
print(f"Percentage: {percentage:.2f}%")
print(f"CGPA: {cgpa:.2f}")
print(f"Grade: {grade}")
output….
\