Python Programming Lab Internal 26/07/2023
Part-A (Anyone)
1. Question: Write a Python code snippet based on the user's score input to
determine the grade. The code should take an integer score as input and use
conditional statements to assign the corresponding grade according to the
following criteria:
- If the score exceeds or exceeds 90, the grade should be 'A'.
- The grade should be' B' if the score is between 80 and 89 (inclusive).
- If the score is between 70 and 79 (inclusive), the grade should be 'C'.
- If the score is between 60 and 69 (inclusive), the grade should be 'D'.
- For any score below 60, the grade should be an 'F'.
Test your code with different score inputs to ensure it assigns the correct
grades and prints the result accurately.
2. Write a Python program that takes the user's age as input and calculates the
ticket price based on the given criteria:
- Children below 5 years old can enter for free, so the ticket price is 0 for them.
- Children between 5 and 11 years old (inclusive) need to pay $10 for a ticket.
- Teenagers between 12 and 17 years old (inclusive) need to pay $15 for a
ticket.
- Adults between 18 and 59 years old (inclusive) need to pay $20 for a ticket.
- Senior citizens aged 60 and above need to pay a discounted price of $10 for a
ticket.
Ensure that your Python program handles different age inputs correctly and
outputs the appropriate ticket price.
Test your code with various age inputs to verify that it correctly calculates and
displays the ticket price based on the age provided.
Part- (Write any 2)
3.) Write a program to find the sum of n numbers
4.) Write a program to find the factorial of a number
5.) Explain the importance of closing a file after writing to it in
Python. What issues may arise if you forget to close the file?