Python Coding Basics Flashcards
6 cards from real Online Coding Lessons practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Python Coding Basics flashcards as text
Which keyword is used to define a function in Python?
Answer: def
In Python, the 'def' keyword is used to define a function.
What is the correct way to print 'Hello, World!' in Python?
Answer: print('Hello, World!')
Python uses the built-in print() function to display output to the console.
Which data type is used to store a sequence of characters in Python?
Answer: str
The 'str' (string) data type in Python is used to store sequences of characters.
What does the len() function do in Python?
Answer: Returns the number of items in an object
The len() function returns the number of items (length) in an object such as a string, list, or tuple.
How do you create a comment in Python?
Answer: # This is a comment
In Python, comments are created using the hash (#) symbol at the start of the line.
Which of the following correctly creates a list in Python?
Answer: myList = [1, 2, 3]
Lists in Python are created using square brackets [] with items separated by commas.