0% found this document useful (0 votes)
12 views

1 A, B Python Program

Python

Uploaded by

dishanaidu575
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

1 A, B Python Program

Python

Uploaded by

dishanaidu575
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1. a.

Develop a program to read the student details like Name, USN, and Marks in
three subjects. Display the student details, total marks and percentage with suitable
messages.
AIM:
To develop a program to read the student details like Name, USN, and Marks in three subjects, and to Display the
student details, total marks and percentage with suitable messages.
ALGORITHM:
1. The program starts by asking the user to input the student's details such as name, USN (University
Serial Number), and marks in three subjects.
2. It calculates the total marks obtained by adding the marks in all three subjects and then calculates the
percentage by dividing the total marks by 300 (assuming each subject has a maximum of 100 marks)
and multiplying by 100.
3. The program then prints the student's details, marks in each subject, total score, and percentage.
4. Next, it uses conditional statements (if-elif-else) to determine the class based on the percentage
obtained:
 If the percentage is 90 or above, it prints "First Class Exemplary."
 If the percentage is between 75 and 89, it prints "First Class with Distinction."
 If the percentage is between 60 and 74, it prints "First Class."
 If the percentage is between 35 and 59, it prints "Second Class."
 If the percentage is below 35, it prints "Fail."
5. Finally, the program displays the appropriate class message based on the percentage obtained by the
student.
PROGRAM:
studentname = input('Enter the Name of the student: ')
usn = input('Enter the USN of the student: ')
m1 = int(input('Enter the mark in the first subject: '))
m2 = int(input('Enter the mark in the second subject: '))
m3 = int(input('Enter the mark in the third subject: '))

total = m1 + m2 + m3
percentage = round((total / 300) * 100)

print('\nName of the Student:', studentname)


print('USN:', usn)
print('Mark in Subject 1:', m1)
print('Mark in Subject 2:', m2)
print('Mark in Subject 3:', m3)
print('Total Score =', total)
print('Percentage =', percentage)

if percentage >= 90:


print('First Class Exemplary.')
elif percentage >= 75:
print('First Class with Distinction.')
elif percentage >= 60:
print('First Class.')
elif percentage >= 35:
print('Second Class.')
else:
print('Fail.')
OUTPUT:
Name of the Student: Vinay R
USN: 1HK22EC0127
Mark in Subject 1: 90
Mark in Subject 2: 95
Mark in Subject 3: 99
Total Score = 284
Percentage = 95
First Class Exemplary.
1. b. Develop a program to read the name and year of birth of a person. Display
whether the person is a senior citizen or not.

AIM: To develop a program for reading the name and year of birth of a person and to display whether the person
is a senior citizen or not.

ALGORITHM:

1. The program starts by asking the user to input the name of the person and their year of birth.
2. It calculates the person's age by subtracting the input year of birth from the current year, which is set as
2024 (current_year - year_of_birth = age).
3. The program then prints the person's name, year of birth, and calculated age using print statements.
These statements are formatted to display the information clearly.
4. Next, the program uses an if-else statement to determine whether the person is a senior citizen or not.
The condition if age >= 60: checks if the calculated age is 60 years or older. If the condition is true, it
prints "The person is a Senior Citizen." Otherwise, it prints "The person is not a Senior Citizen."

PROGRAM:
person_name = input('Enter the Name of the person: ')
year_of_birth = int(input('Enter the Year of Birth: '))
current_year = 2024
age = current_year - year_of_birth

print('\nName of the person:', person_name)


print('Year of Birth of the person:', year_of_birth)
print('Age of the person:', age)

if age >= 60:


print('The person is a Senior Citizen.')
else:
print('The person is not a Senior Citizen.')

OUTPUT:
Enter the Name of the person: John Doe
Enter the Year of Birth: 1955

Name of the person: John Doe


Year of Birth of the person: 1955
Age of the person: 68
The person is a Senior Citizen.

You might also like