IT-Phython Flashcards

(20 cards)

1
Q

What are the syntax rules in programming?

A

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

Syntax rules ensure that the code is correctly formatted for the programming language being used.

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

What are naming rules in programming?

A

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

Clear naming conventions improve code readability and maintainability.

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

What are control rules?

A

Decide how the program runs, including sequence, selection, and iteration

Control rules govern the logic and flow of the program’s execution.

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

What is sequence in programming?

A

Outlines how steps run in order

Sequence is the default control structure where instructions are executed linearly.

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

What is selection in programming?

A

Making decisions using if or else

Selection allows for conditional execution of code blocks.

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

What is iteration in programming?

A

Repeating steps using loops (e.g. for, while)

Iteration is used to execute a block of code multiple times.

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

What are validation rules?

A

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

Validation rules help ensure that input data adheres to specified criteria.

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

What are error handling rules?

A

What to do if something goes wrong

Error handling ensures that the program can manage unexpected issues gracefully.

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

What are the different data types in programming?

A
  • Strings
  • Integers
  • Floats
  • Lists
  • Dictionaries

Each data type serves a specific purpose in programming, affecting how data is stored and manipulated.

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

What is a string in programming?

A

A sequence of characters enclosed in quotes. Example: name = ‘Bob’

Strings are commonly used to represent text.

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

What is an integer in programming?

A

A whole number with no decimal point. Example: age = 30

Integers are used for counting and indexing.

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

What is a float in programming?

A

A number that has a decimal point. Example: price = 19.99

Floats are used for representing precise values like currency.

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

What is a list in programming?

A

An ordered collection of items (any type) enclosed in square brackets. Example: colors = [‘red’, ‘green’, ‘blue’]

Lists allow for storing multiple items in a single variable.

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

What is a dictionary in programming?

A

A collection of key-value pairs enclosed in curly braces. Example: person = {‘name’: ‘Bob’, ‘age’: 30, ‘city’: ‘Ballarat’}

Dictionaries provide a way to store data that can be accessed by a unique key.

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

What are control structures?

A

Used to control the flow of a program. Common ones include conditional logic and loops

Control structures are essential for creating dynamic and functional programs.

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

What is conditional logic in programming?

A

if / elif / else statements. Example: if age > 18: print(‘Adult’)

Conditional logic allows the program to execute different code paths based on conditions.

17
Q

What is a loop in programming?

A

for / while structures. Example: for color in colors: print(color)

Loops enable repetitive execution of code, which is useful for processing collections.

18
Q

What is a module in programming?

A

A file containing Python code (functions, variables, classes) that can be imported and used in your program. Example: import math

Modules promote code reuse and organization.

19
Q

What is a variable in programming?

A

Stores data that can be used and changed throughout a program. Examples: message = ‘Welcome!’, count = 5

Variables are fundamental for holding values that can be manipulated.

20
Q

What does the print() function do?

A

Displays output to the console. Example: print(‘Hello, Bob!’)

The print function is commonly used for debugging and user interaction.