Complete these exercises to reinforce your understanding of Python Basics. Try to solve them on your own before checking the solutions!
Exercise 1: Personal Information
EasyCreate a program that asks for user's name, age, and city, then displays a formatted message with all the information.
💡 Hints
- Use the input() function to get user data
- Store each piece of information in a variable
- Use f-strings to format the output message
Exercise 2: Basic Calculator
EasyBuild a simple calculator that takes two numbers and an operator (+, -, *, /) and performs the calculation.
💡 Hints
- Get two numbers from user input and convert to float
- Get the operator as a string
- Use if-elif statements to perform the right operation
Exercise 3: Temperature Converter
EasyConvert temperatures between Celsius and Fahrenheit. Formula: F = C * 9/5 + 32
💡 Hints
- Ask which conversion direction (C to F or F to C)
- Get the temperature value
- Apply the appropriate formula
Exercise 4: String Manipulation
MediumTake a sentence from the user and display: word count, character count, uppercase version, lowercase version, and title case version.
💡 Hints
- Use .split() to count words
- Use len() for character count
- Use string methods like .upper(), .lower(), .title()
Exercise 5: Shopping Cart Total
MediumCalculate the total cost of items in a shopping cart including tax. Ask for item prices and calculate subtotal, tax (8%), and total.
💡 Hints
- Store prices in variables
- Calculate subtotal by adding all prices
- Calculate tax as 8% of subtotal
- Add subtotal and tax for total
Ready to check your work?
View the solutions to see how you did and learn best practices.
View Solutions