6. Python

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/32

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:41 PM on 5/26/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

33 Terms

1
New cards

What does dynamically typed mean

Python is dynamically typed — types are determined at runtime, not declared in advance

2
New cards

Is python interpreted or translated

Python source code is executed line by line by an interpreter.

3
New cards

What paradigms does python support

Procedural, object oriented and functional styles

4
New cards

What is a REPL

Read - eval - print loop

Interactive interpreter where you type and run code one line at a time

5
New cards

What is semantic whitespace

indentation that defines code structure

6
New cards

What does python use instead of braces

Indentation

7
New cards

What does python use instead of semicolons

Nothing — statements end at the line break

8
New cards

How do you write a comment in python

# comment here

9
New cards

how do you find the type of a variable in python

type(x)

10
New cards

How is boolean true and false written in python

True and False

11
New cards

How do you cast data types in python

int(“5)

float(3)

str(42)

list(“abc”)

12
New cards

How do you create a list in python

empty = []
numbers = [1, 2, 3, 4, 5]
mixed = [1, "two", 2, 3.24, True, None]
nested = [[1, 2], [3, 4]]

13
New cards

how do you add items to a list in python

lst.append(x)

14
New cards

how do you insert items into a list

lst.insert(i, x)

i for index

x for data

15
New cards

how do you remove items from a list in python

list.remove(x)

removes first instance of x

16
New cards

How do you get the length of the list

len(lst)

17
New cards

how do you check if an item is in a list in python

x in lst

18
New cards

What is a tuple in python

A list that cannot be changed (immutable)

basically a const list

19
New cards

How do you create a dictionary in python

empty = {}
person = {"name": "Alice", "age": 30}
# like a list but with names

20
New cards

What is a set in python

An unordered collection of unique items

  • removes duplicates

  • has no order

21
New cards

How do you get the length of a string in python

len(string)

22
New cards

what actions can you perform on a string

s.upper()

s.lower()

s.strip() — removes leading / tailing whitespace

23
New cards

what does s.split(“,”) do

splits the data in the string (s), based on the identification of the delimiter (“,”). returns in a list

24
New cards

How can you concatenate with strings and variables

greeting = f"Hello, {name}"

25
New cards

what does an if statement look like in python

if score >= 70:
	grade = "distinction"
elif score >= 50:
	grade = "pass"
else:
	grade = "fail"

26
New cards

what does a while loop look like in python

while count < 10:
	print(count)
	count += 1

27
New cards

what does a for loop look like in python

for i in range(10):
	print(i)

28
New cards

what does loop control contain in python

break — exit loop

continue — skip to next iteration

29
New cards

how do you define a function in python

def add(a, b):
	return a + b

result = add(3, 5);

30
New cards

how do you define a class in python

class Car:
	def __init__(self, colour):
		self.colour = colour
		self.miles_driven = 0
	
	def drive(self, miles):
		self.miles_driven += miles
	
	def get_colour(self):
		return self.colour

31
New cards

how do you create an object in python

c = Car("white")
c.drive(100);

32
New cards

how does inheritance work in python

class Mammal: 
	def __init__(self, name):
		self.name = name

class Person(Mammal):
	def __init__(self, name, age):
		super().__init__(name)
		self.age = age

33
New cards

How does exception handling work in python

try:
	x = int(input("Enter a number:"))
	y = 10 / x
	print(y)
except ValueError:
	print("That wasn't a number")
except ZeroDivisonError:
	print("Can't divide by zero")
except Exception as e:
	prin("Error: {e}")