Curriculum
Objective
Practice using the input()
and print()
functions to collect user input and display a message.
Instructions
"Hello, John Doe! Welcome to Python programming."
Example Output
Enter your first name: John
Enter your last name: Doe
Hello, John Doe! Welcome to Python programming.
Objective
Learn how to convert input from strings to integers and perform basic arithmetic operations.
Instructions
int()
.Example Output
Enter first number: 8
Enter second number: 3
Sum: 11
Difference: 5
Product: 24
Objective
Use Python f-strings to produce a clean and readable output that includes user-provided values.
Instructions
"Alice's favorite number is 7."
Example Output
Enter your name: Alice
Enter your favorite number: 7
Alice's favorite number is 7.
Solution to Exercise 1
first_name = input("Enter your first name: ")
last_name = input("Enter your last name: ")
print("Hello,", first_name, last_name + "! Welcome to Python programming.")
Solution to Exercise 2
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("Sum:", num1 + num2)
print("Difference:", num1 - num2)
print("Product:", num1 * num2)
Solution to Exercise 3
name = input("Enter your name: ")
fav_number = int(input("Enter your favorite number: "))
print(f"{name}'s favorite number is {fav_number}.")
Not a member yet? Register now
Are you a member? Login now