0% found this document useful (0 votes)
43 views2 pages

Python Programs for Student Details and Age

Python

Uploaded by

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

Python Programs for Student Details and Age

Python

Uploaded by

dishanaidu575
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

Common questions

Powered by AI

Conditional statements enhance program flexibility and utility by allowing the program to make decisions based on variable conditions, adapting output or procedures dynamically. They enable the program to handle diverse scenarios through branching logic, improving user interactivity through tailored responses. This adaptability makes programs useful in real-world applications where inputs or environments are unpredictable, facilitating more sophisticated and personalized outputs .

Audience awareness in educational software design significantly influences user interface complexity, accessibility, and content type. Software tailored for younger audiences or novices may emphasize intuitive interfaces and step-by-step guidance. Advanced users may require detailed, customizable features supporting diverse learning styles. Cultural and educational backgrounds also necessitate adaptable content presentation to align with varied educational standards and linguistic needs. Design considerations for cognitive load and engagement levels are crucial, as improperly aligned software risks disengagement or misunderstanding .

When creating user-input driven applications, considerations include validation of input to prevent errors from invalid or unexpected data types, such as ensuring numerical input when expected. Providing clear instructions and feedback to users enhances usability and reduces input errors. Implementing exception handling ensures the program can manage incorrect inputs gracefully without crashing, and considerations for accessibility and user experience should be prioritized to accommodate a wide range of users .

Utilizing print statements is beneficial for debugging purposes, offering a simple way to trace program execution and verify state variables at certain points. They help in providing immediate feedback, making them useful for educational demonstrations and simple user-interface communication. However, potential drawbacks include cluttered program output, especially if not removed after testing, and negatively affecting performance in production environments through unnecessary logging. They lack flexibility for formatted output compared to logging tools designed for various levels of verbosity and customizability .

To develop a program that calculates and displays student academic performance, several key components are essential: reading student details such as Name, USN, and Marks in subjects; computing total marks by summing up subject scores; calculating the percentage with the formula (total marks / 300) * 100; and printing student details along with total marks and percentage. The program also uses conditional statements to categorize student performance into classes based on the percentage: 'First Class Exemplary' for 90% and above, 'First Class with Distinction' for 75%-89%, 'First Class' for 60%-74%, 'Second Class' for 35%-59%, and 'Fail' for below 35% .

Using a fixed 'current year' value in age calculation programs can lead to inaccuracies, as the program becomes outdated when the actual current year changes, affecting the accuracy of age calculations. This method lacks flexibility, requiring manual updates annually, and does not account for runtime changes or deployment at different times, leading to potential user errors or misinterpretation of the calculated age .

The percentage calculation is essential before determining the class category because it standardizes students' performance across varying scales of assessment into a uniform reference frame, enabling proportional evaluation. The class category relies on predefined percentage thresholds to categorize performance into qualitative descriptions such as 'First Class' or 'Second Class.' This normalization simplifies condition checking within the program, allowing the use of direct conditional statements to assign performance classes consistently and accurately based on computed percentages .

The algorithm determines if someone is a senior citizen by first calculating the person's age, which is done by subtracting the birth year from the current year (2024). It then uses an if-else statement to check if the calculated age is greater than or equal to 60. If true, it prints 'The person is a Senior Citizen,' otherwise, it prints 'The person is not a Senior Citizen' .

Threshold values in programming serve as critical reference points to classify data into predefined categories. They streamline decision-making processes by demarcating limits beyond which outcomes bifurcate into different categories, such as grading students by performance metrics. Establishing these values involves weighing domain-specific norms and data distribution; rigid or inappropriate thresholds can skew classifications, leading to misrepresentations or errors. Proper use ensures efficient categorization without requiring extensive conditional logic, enhancing both processing speed and clarity in the categorization outcomes .

The threshold for passing in the student performance program is set at 35%, categorizing any percentage below this as a 'Fail.' This reflects educational systems where a passing grade is usually a minimal competence threshold, underscoring mastery of subject material at a basic level. However, this threshold may vary in different educational systems, where passing criteria could be higher or lower, based on institutional or regional educational standards. The program's classification creates predefined categories that may not align universally, highlighting the subjectivity in educational grading systems .

You might also like