Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
What is Python
📖 Scenario: Imagine you want to learn a new language that helps you talk to computers. Python is one of the easiest and most popular languages to start with.
🎯 Goal: You will write a simple Python program that shows what Python is by printing a short message.
📋 What You'll Learn
Create a variable with a message about Python
Print the message to the screen
💡 Why This Matters
🌍 Real World
Python is used by many people to create websites, games, and apps because it is easy to learn and very powerful.
💼 Career
Knowing Python can help you get jobs in software development, data science, automation, and many other technology fields.
Progress0 / 4 steps
1
Create a message about Python
Create a variable called message and set it to the text 'Python is a simple and powerful programming language.'
Python
Hint
Use the equals sign = to assign the text to the variable message.
2
Print the message
Use the print() function to display the content of the variable message on the screen.
Python
Hint
Write print(message) to show the message on the screen.
3
Run the program
Run the program to see the message about Python printed on the screen.
Python
Hint
Click the run button or run the script to see the message appear.
4
Understand the output
Look at the output and understand that Python helps us tell the computer what to do using simple words.
Python
Hint
The output shows the message stored in the variable. This is how Python communicates with us.
Practice
(1/5)
1. What is Python primarily used for?
easy
A. Designing buildings and architecture
B. Writing instructions for computers in a simple way
C. Cooking recipes automatically
D. Painting pictures with a brush
Solution
Step 1: Understand Python's purpose and compare options
Python is a programming language used to tell computers what to do. Only Writing instructions for computers in a simple way describes writing instructions for computers simply, which matches Python's use.
Final Answer:
Writing instructions for computers in a simple way -> Option B
Quick Check:
Python = simple computer instructions [OK]
Hint: Python is for coding, not cooking or painting [OK]
Common Mistakes:
Confusing Python with non-programming tasks
Thinking Python is a tool for art or cooking
Mixing Python with unrelated professions
2. Which of the following is the correct way to start a Python program?
easy
A. print('Hello, world!')
B. echo 'Hello, world!'
C. console.log('Hello, world!')
D. System.out.println('Hello, world!')
Solution
Step 1: Identify Python syntax for output and check options
Python uses the print() function to show text on the screen. print('Hello, world!') uses print(), which is Python syntax; others belong to different languages.
Final Answer:
print('Hello, world!') -> Option A
Quick Check:
Python output uses print() [OK]
Hint: Python uses print() to show messages [OK]
Common Mistakes:
Using commands from other languages like echo or console.log
Confusing syntax from Java or JavaScript
Missing parentheses in print function
3. What will this Python code print?
name = 'Alice'
print(f'Hello, {name}!')
medium
A. Hello, Alice!
B. Hello, name!
C. Hello, {name}!
D. Error: invalid syntax
Solution
Step 1: Understand f-string usage and replace variable
The code uses an f-string to insert the value of variable name inside the string. Variable name is 'Alice', so the output becomes 'Hello, Alice!'.
Final Answer:
Hello, Alice! -> Option A
Quick Check:
f-string inserts variable value [OK]
Hint: f-strings show variable values inside strings [OK]
Common Mistakes:
Thinking it prints the variable name as text
Confusing f-string syntax with regular strings
Expecting a syntax error due to unfamiliar syntax
4. Find the error in this Python code:
for i in range(3)
print(i)
medium
A. Variable 'i' is not defined
B. Incorrect indentation of print statement
C. Missing colon ':' after range(3)
D. Wrong function name 'range'
Solution
Step 1: Check for syntax errors in for loop and identify issue
Python requires a colon ':' at the end of the for statement line. The code misses ':' after range(3), causing a syntax error.
Final Answer:
Missing colon ':' after range(3) -> Option C
Quick Check:
for loops need ':' at end [OK]
Hint: Always put ':' after for loops [OK]
Common Mistakes:
Forgetting the colon ':' after loop header
Misaligning indentation but colon is more critical
Thinking 'range' is misspelled
5. You want to create a simple Python program that asks for your name and then greets you. Which code correctly does this?
hard
A. input('Enter your name: ')
print('Hello, {name}!')
B. print('Enter your name: ')
name = input
print('Hello, name!')
C. name = input('Enter your name: ')
print('Hello, name!')
D. name = input('Enter your name: ')
print(f'Hello, {name}!')
Solution
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.
Final Answer:
name = input('Enter your name: ')
print(f'Hello, {name}!') -> Option D
Quick Check:
input() + f-string greet = correct [OK]
Hint: Use input() to get text, f-string to show it [OK]