FlashKeepers

Python · Python · College and University

Python Basics: Syntax and Data Types

Core Python syntax, variable types, and common data structures (lists, dicts, tuples) explained with a short example each.

About this set

43 basic cards for Python Python. Set 2 of 2 in Python Basics. It opens with "What is a variable in Python?" and "How do you assign a value to a variable in Python?". More College and University decks are listed below.

43 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is a variable in Python?
Show answerA named container that stores a value. You assign it once and can refer to it by name throughout your code.
How do you assign a value to a variable in Python?
Show answerUse the equals sign (=). Example: name = 'Alice'
What is dynamic typing in Python?
Show answerThe type of a variable is determined by the value assigned to it at runtime, and can change if reassigned.
What is the int data type in Python?
Show answerA data type for whole numbers without a decimal point. Example: x = 5
What is the float data type in Python?
Show answerA data type for numbers with a decimal point. Example: pi = 3.14
What is the str data type in Python?
Show answerA sequence of characters enclosed in quotes (single, double, or triple). Example: text = 'Hello'
What is the bool data type in Python?
Show answerA data type with only two values: True or False.
How do you create a list in Python?
Show answerUse square brackets with comma-separated values. Example: nums = [1, 2, 3]
How do you access a single element in a list?
Show answerUse the index in square brackets. Example: nums[0] returns the first element.
What is list indexing in Python?
Show answerThe position of an element in a list, starting from 0 for the first element.
What is negative indexing in Python?
Show answerUsing negative numbers to index from the end of a list. Example: nums[-1] is the last element.
How do you add an element to a list?
Show answerUse the append() method. Example: nums.append(4) adds 4 to the end.
How do you remove an element from a list?
Show answerUse remove() to delete by value, or pop() to delete by index. Example: nums.remove(2) or nums.pop(0)
What is a tuple in Python?
Show answerAn ordered collection of elements enclosed in parentheses that cannot be changed after creation.
How do you create a tuple?
Show answerUse parentheses with comma-separated values. Example: coords = (10, 20)

28 more cards in the app

Study this set free