Python is a popular programming language. What is its main use?
Think about what programming languages help create.
Python is widely used to build websites, web apps, and many other software projects.
Look at this code and tell what it prints:
print(type('Hello'))print(type('Hello'))
What type is a text inside quotes in Python?
Text inside quotes is a string, so type('Hello') returns <class 'str'>.
What does this code print?
def greet(name):
return f"Hello, {name}!"
print(greet('Alice'))def greet(name): return f"Hello, {name}!" print(greet('Alice'))
Look at how the function uses the name inside the string.
The function returns a greeting with the given name inserted, so it prints 'Hello, Alice!'.
Python has many features. Which one below is NOT true about Python?
Think about how Python handles memory compared to lower-level languages.
Python manages memory automatically, unlike C which requires manual memory management.
What does this code print?
nums = [1, 2, 3, 4, 5]
if (n := len(nums)) > 3:
print(f"List has {n} items")
else:
print("List is small")nums = [1, 2, 3, 4, 5] if (n := len(nums)) > 3: print(f"List has {n} items") else: print("List is small")
The walrus operator assigns and returns the value in one step.
The length of the list is 5, which is greater than 3, so it prints 'List has 5 items'.