name = input("Enter your name: ")
age = input("Enter your age: ")
print(f"My name is {name} and I am {age} years old.")
#source code --> clcoding.com
Code Explanation:
Take user input for name and age
name = input("Enter your name: ") → Stores the user’s name.
age = input("Enter your age: ") → Stores the user’s age as a string.
Use an f-string for formatted output
f" My name is {name} and I am {age} years old."
The {name} and {age} placeholders are replaced by the actual values entered by the user.
Print the formatted sentence
The program prints a complete sentence with the user's details.
0 Comments:
Post a Comment