Exercise 1: Basic Numeric Operations
Write a program that prompts the user to enter two numbers. Calculate and display the sum, difference, product, and quotient of these two numbers. Check and display the data types of the entered numbers and the results.
Exercise 2: Random Number Generator
Write a program that imports the random module. Generate and print five random integers between 1 and 100. Then, generate and print a random floating-point number between 0 and 1.
Exercise 3: String Manipulation
Write a program that prompts the user to enter their first name and last name. Concatenate the first name and last name into a full name and print it. Then, slice and print the first three letters of the first name and the last three letters of the last name.
Exercise 4: Type Conversion
Write a program that prompts the user to enter a floating-point number. Convert the floating-point number to an integer and print the result. Then, convert the integer back to a floating-point number and print the result.
Exercise 5: Test Scores Calculator
Write a program that prompts the user to enter three test scores. Calculate the sum and average of the test scores. Print the sum and average of the scores with appropriate labels.
Exercise 6: String Handling and Quotation Marks
Write a Python program that assigns the following text to a variable and prints it: He said, "Python's flexibility with strings is amazing!". Use both single and double quotation marks appropriately to avoid escape characters.
Exercise 7: Multi-line Strings and Slicing
Create a multi-line string variable with a short paragraph about your favorite hobby. Print the entire paragraph and then print a slice of the string that contains the first ten characters. Finally, print every second character from the slice.
Exercise 8: String Concatenation
Write a Python program that asks the user to input their first name and last name separately. Concatenate these inputs with a space in between to form their full name, and print the full name with the message: "Your full name is: <full_name>".
Exercise 9: String Formatting with f-strings
Develop a Python program that prompts the user to enter their name, age, and favorite color. Use an f-string to format and print a message that says: "Hello, my name is <name>, I am <age> years old, and my favorite color is <color>."
Exercise 10: Boolean Expressions and Comparison Operators
Write a Python program that asks the user for the price of two different items. Compare the prices using comparison operators and print out which item is more expensive, or if they are priced the same. Use the format method to create the output message.