Bird
0
0

You want to create a simple Python program that asks for your name and then greets you. Which code correctly does this?

hard📝 Application Q15 of 15
Python - Basics and Execution Environment
You want to create a simple Python program that asks for your name and then greets you. Which code correctly does this?
Ainput('Enter your name: ') print('Hello, {name}!')
Bprint('Enter your name: ') name = input print('Hello, name!')
Cname = input('Enter your name: ') print('Hello, name!')
Dname = input('Enter your name: ') print(f'Hello, {name}!')
Step-by-Step Solution
Solution:
  1. Step 1: Use input() to get user input and f-string to greet

    name = input('Enter your name: ') print(f'Hello, {name}!') correctly assigns the input to variable name and uses f-string print(f'Hello, {name}!') to show the greeting with the actual name.
  2. Final Answer:

    name = input('Enter your name: ') print(f'Hello, {name}!') -> Option D
  3. Quick Check:

    input() + f-string greet = correct [OK]
Quick Trick: Use input() to get text, f-string to show it [OK]
Common Mistakes:
MISTAKES
  • Not assigning input to a variable
  • Printing variable name as text instead of value
  • Missing parentheses in input or print

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes