Python Flashcards

(39 cards)

1
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
2
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
3
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
4
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
5
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
6
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
7
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
8
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
9
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
10
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
11
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
12
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
13
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
14
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
15
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
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

17
Q

Variables

A

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

18
Q

Print Statements

A

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

19
Q

Boolean

A

A data type that represents one or two values: True or False.

20
Q

Casting

A

The process of converting one data type to another. Example: int(input(“Enter a number”)) converts a string to an integer

21
Q

Function

A

A pre-made block of code designed to perform a specific task. Examples include print() and input()

22
Q

Input Function

A

A function that promotes the use to enter data, which is stored as a string. Example: input(“What is your name?”)

23
Q

Print Function

A

a function used to display an output of the screen. Example: print(“Hello World”). Also known as a print statement

24
Q

Syntax error

A

An error caused by breaking the rules of the programming language, such as incorrect punctuation or spacing.

25
Evaluation
determining the value of an expression as True or False
26
Selection
enabling computers to perform different actions based on if conditions are true or false
27
==, !=, <, >
Different comparison operators used to compare values in python
28
and, or
applying logic operations to conditions
29
indentation
adding spaces to the start of lines of code in Python so that it understands the scope
30
condtion
an expression that can be evaluated as either true of false
31
if, then, else
tools, for making code run depending whether a statement is true of false
32
scope
defines which code belongs to which part of the program
33
code
the instructions within a program
34
variable
a stored value in your program that is references by a name
35
data type
defines the type of data stored in a variable (string, integer)
36
bug
a problem with a program not behaving as intended
37
debugging
the process of find and correcting bugs
38
IDE
integrated development environment
39
syntax
the correct structure or layout of code