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

Section 3 Assignment

Uploaded by

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

Section 3 Assignment

Uploaded by

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

Assignment S3

Q1) Write a Python program that asks the user for their age and then classifies them
into one of the following categories:

• 0-12: Child
• 13-19: Teenager
• 20-64: Adult
• 65+: Senior

Instructions:
1. Ask the user to input their age.
2. Use if-elif-else statements to determine their category.
3. Print the result.

Q2) Write a Python program that checks if a number is divisible by both 3 and 5.

Instructions:
1. Ask the user to input a number.
2. Use an if-elif-else statement to check if the number is divisible by 3, 5, both, or
neither.
3. Print the appropriate result.

Q3) Write a Python program that converts temperatures between Celsius and
Fahrenheit. The user should input the temperature and the scale (C for Celsius or F
for Fahrenheit), and the program should convert to the opposite scale.

Instructions:
1. Ask the user to input the temperature value and scale (C/F).
2. Use if-elif-else statements to check the scale and convert the temperature.
3. Print the converted temperature.
Formulae:
• Celsius to Fahrenheit: (C × 9/5) + 32
• Fahrenheit to Celsius: (F - 32) × 5/9

Computer Graphics Fall 2024 Faculty of Engineering CSE department


Q4) Write a Python program that lets two players play the classic Rock, Paper,
Scissors game. The program should ask each player to enter their choice and then
determine the winner.

Instructions:
1. Use if-elif-else statements to determine the winner based on the players' inputs.
2. Use the rules:
o Rock beats Scissors.
o Scissors beat Paper.
o Paper beats Rock.

Q5) Write a Python program that acts as a simple calculator. The program should
ask the user to input two numbers and an operator (+, -, *, /), then perform the
corresponding calculation.

Instructions:
1. Ask the user for two numbers and an operator.
2. Use if-elif-else to handle the operation and print the result.
3. Make sure to handle division by zero.

Computer Graphics Fall 2024 Faculty of Engineering CSE department

You might also like