Python Flashcards

Python (23 cards)

1
Q

Boolean

A

A data type that is either true or false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Rule

A

A rule in programming is a guideline that tells you how code should be written and behave. These rules help make sure your program works properly and is easy to understand.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Syntax rules

A

Using the correct structure (e.g. brackets, semicolons).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Naming rules

A

Using clear names for variables (e.g. totalMarks, not x).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Control rules

A

Deciding how the program runs and can include: sequence, selection and iteration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Sequence

A

is a control rule and outlines how steps run in order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Selection

A

is a control rule about making decisions (if, else).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Iteration

A

is a control rule about repeating steps (for, while loops).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Validation rules

A

Checking if data is correct (e.g. age must be between 0–120).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Error handling rules

A

What to do if something goes wrong.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Strings

A

A string is a sequence of characters enclosed in quotes. It can include letters, numbers, symbols, and spaces. For example: name = “Bob”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Integers

A

An integer is a whole number (no decimal point). For example: age = 30

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Floats

A

A float is a number that has a decimal point. For example: price = 19.99

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Lists

A

A list is an ordered collection of items (which can be of any type), enclosed in square brackets. For example: colors = [“red”, “green”, “blue”]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Dictionaries

A

A dictionary is a collection of key-value pairs, enclosed in curly braces. For example: person = {“name”: “Bob”, “age”: 30, “city”: “Ballarat”}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Control Structures

A

These are used to control the flow of a program. Common ones include:
if/elif/else: Conditional logic.
For example:
# if statement
if age > 18:
print(“Adult”)
for and while loops: Repeating actions
For example:
# for loop
for color in colors:
print(color)

17
Q

Modules

A

A module is a file containing Python code (functions, variables, classes) that you can import and use in your program. For example: import math

18
Q

Variables

A

A variable stores data that can be used and changed throughout a program. For example:
message = “Welcome!”
count = 5

19
Q

Print Statements

A

The print() function displays output to the console. print(“Hello, Bob!”)

20
Q

Function

A

A pre-made block of code that performs a specific function, e.g: print() and return().

21
Q

Input

A

Displays text and collects any responses.

22
Q

Print

A

Displays text on the screen.

23
Q

Syntax error

A

An error caused by invalid code, which breaks the rules of the programming language.