Exercise 1: Variable Naming and Assignment
Write a Python program that defines variables for storing a person's name, age, and country of residence. Ensure the variable names follow Python's naming conventions.
Exercise 2: Basic Input/Output
Create a program that asks the user for their name and age, then prints a message saying how old they will be in 5 years.
Exercise 3: Arithmetic Expressions
Write a program that takes two numbers from the user and prints the result of their addition, subtraction, multiplication, and division.
Exercise 4: Conditional Letter Grades
Develop a program that prompts the user for a score (0-100). Based on the score, output the corresponding letter grade (A, B, C, D, F), following a standard grading scale.
Exercise 5: Temperature Converter
Implement a program that converts temperature from Fahrenheit to Celsius. The user should enter the temperature in Fahrenheit, and the program should output the temperature in Celsius.
Exercise 6: Simple Interest Calculator
Write a Python script that calculates simple interest given the principal amount, rate of interest, and time period.
Use the formula:
simple_interest = (principal * rate * time) / 100
Exercise 7: Swapping Two Variables
Create a program that demonstrates swapping the values of two variables using multiple assignment. The initial values should be input by the user.
Exercise 8: User Input Validation
Develop a program that continuously prompts the user for a number between 1 and 10. The program should not terminate until the user inputs a valid number within the specified range.
Exercise 9: Basic Calculator for Two Numbers
Implement a simple calculator that takes two numbers and an operator (+, -, *, /) as input from the user, then prints the result of the operation.
Exercise 10: Debugging Practice
Given a piece of code that is supposed to calculate the average of three test scores but contains errors, identify and correct the errors to ensure the program runs correctly.
score1 = input("Enter score 1: ") score2 = input("Enter score 2: ") score3 = input("Enter score 3: ") average = (score1 + score2 + score) / 3 print("The average score is: ", average) |