Why it worked
The video provides a clear and concise explanation of basic Python programming concepts, including user input, string formatting, and data type conversion. This makes it valuable for beginners learning to code.
Summary
The video demonstrates Python code that takes user input for their name, age, and favorite number. It then processes this information to display it in different formats, including uppercase, title case, and calculates age in months, while also showing the data types of the collected inputs.
Structure
- 1Introduce Python code for user input
- 2Demonstrate taking first name, age, and favorite number
- 3Combine name and surname into a full name
- 4Display output in uppercase and title case
- 5Calculate and display age in months
- 6Round favorite number to two decimal places
- 7Show data types of collected values
On-screen text
challenge_1.py
first_name
first_name = input("Enter your first name: ")
age = int(input("Enter your age: "))
Favourite_number = float(input("Enter your favourite number: "))
full_name = f"{first_name} {surname}"
print(f"WELCOME, {full_name}")
print(f"UPPERCASE: {full_name.upper()}")
print(f"TITLE CASE: {full_name.title()}")
age_in_months = age * 12
print(f"Age in months: {age_in_months}")
rounded_favourite_number = round(favourite_number, 2)
print(f"Favourite number (rounded to 2 decimal places): {rounded_favourite_number}")
print("\nData types of collected values:")
print(f"first_name: {type(first_name)}")
print(f"surname: {type(surname)}")
print(f"age: {type(age)}")
print(f"Favourite_number: {type(favourite_number)}")