Y9 Advanced Python Revisio

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

1/23

encourage image

There are no tags or description

Looks like no tags are added yet.

24 Terms

1
New cards

What is sequence in programming?

Instructions execute one after another in order.

2
New cards

What is a variable?

A space in memory used to store data.

3
New cards

What is a constant, and how does it differ from a variable?

A constant should not change while a program runs, whereas a variable can change.

4
New cards

What is input, and which Python command allows users to enter data?

Input is data entered by a user. The command is  input()

5
New cards

What is concatenation, and which operator is used?

Joining pieces of text together using the + operator.

6
New cards

What are the three main Python data types, and how is it typed in a code?

•String – str()

•Integer – int()

•Float – float()

7
New cards

What are arithmetic operators, and what are their Python symbols?

•Addition +

•Subtraction -

•Multiplication *

•Division /

•Exponentiation **

•Modulus %

•Floor division //

8
New cards

What is the difference between modulus (%) and floor division (//)?

Modulus returns the remainder; floor division returns the whole-number result rounded down.

9
New cards

What is casting, and why is it used?

Converting data from one data type to another so it can be used correctly.

10
New cards

What is selection?

Allowing a program to make decisions based on conditions / where a section of code is run only if a condition is met.

11
New cards

What are the purposes of if, elif and else?

•if – Checks the first condition.

•elif – Checks another condition.

•else – Runs if none of the conditions are true.

12
New cards

What is a loop in programming?

A structure that repeats a section of code.

13
New cards

What does range(5) produce?

0, 1, 2, 3, 4

14
New cards

What is a while loop, and when does it stop?

A condition-controlled loop that repeats whilst a condition is true. It stops when the condition becomes false.

15
New cards

What is the difference between a for loop and a while loop?

A for loop repeats a known number of times; a while loop repeats whilst a condition is true.

16
New cards

What is a list, and how is one written in Python?

A collection that stores multiple values in one variable, using square brackets [].

17
New cards

What is an index position, and what number does indexing start at?

The numbered position of an item. Indexing starts at 0.

18
New cards

What do .append() and .remove() do?

.append() adds an item to a list, .remove() removes an item.

19
New cards

What is string manipulation?

Accessing or changing parts of text using index positions.

20
New cards

What is a function (subroutine)

A reusable section of code that reduces repetition

21
New cards

Which Python keyword defines a function, and how do you call it?

Use def to define it and its name followed by brackets to call it.

22
New cards

What is a parameter in a function?

A value or variable passed into a function.

23
New cards

What does def shapeArea(length, width): define?

A function with two parameters: length and width.

24
New cards

What does area = length * width calculate?

The area of a rectangle / square.