Additional Programming Techniques (2)

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

1/59

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:20 PM on 4/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

60 Terms

1
New cards

String manipulation

String manipulation is the use of programming techniques to modify, analyse or extract information from a string.

2
New cards

Case conversion

Case conversion is the ability to change a string from one case to another, e.g. lowercase to uppercase.

3
New cards

Length (string manipulation)

Finding the length refers to the ability to count the number of characters in a string.

4
New cards

Substring

A substring is the ability to extract a sequence of characters from a larger string using slicing.

5
New cards

Concatenation

Concatenation is the ability to join two or more strings together to form a single string using the + operator.

6
New cards

ASCII conversion

ASCII conversion is the ability to return an ASCII character from a numerical value and vice versa.

7
New cards

True or False? In Python substrings are indexed from 0.

True. In Python, substrings are indexed starting from 0, not 1. This is called 0-indexing.

8
New cards

name = "sarah" Write Python code to output the variable name in uppercase.

print(name.upper())

9
New cards

password = "letmein" Write Python code to output the length of the variable "password".

print(len(password))

10
New cards

FName = "Save" SName = "MyExams" Write Python code to output the two variables joined together (concatenation).

print(FName + SName)

11
New cards

File handling

File handling is the use of programming techniques to work with information stored in text files.

12
New cards

Write Python code to open a text file named "fruit.txt" in read only mode.

file = open("fruit.txt", "r")

13
New cards

Write Python code to close a text file.

file.close()

14
New cards

Write Python code to read a line in a text file.

file.readline()

15
New cards

Write Python code to write the value "Oranges" to an open text file

file.write("Oranges")

16
New cards

What does "r" mode do when opening a file?

The "r" mode is used for opening a file in read-only mode.

17
New cards

What does "w" mode do when opening a file?

The "w" mode is used for opening a file in write mode, creating a new file if it doesn't exist, or overwriting an existing file.

18
New cards

What does "a" mode do when opening a file?

The "a" mode is used for opening a file in append mode, writing to the end of an existing file.

19
New cards

True or False? It's important to make a backup of text files before working with them.

True. It's important to make a backup of text files before working with them, as mistakes can lead to data loss.

20
New cards

Database

A database is an organised collection of data that allows easy storage, retrieval, and management of information.

21
New cards

Field

A field is one piece of information relating to one person, item or object, represented as a column in a database.

22
New cards

Record

A record is a collection of fields relating to one person, item or object, represented as a row in a database.

23
New cards

Array (storing data)

Useful when working with small amounts of data, stored in main memory (RAM).

24
New cards

What is an advantage of using a database?

Advantages of databases include: efficient sorting and searching of large amounts of data multiple user access better security than text files.

25
New cards

What is a disadvantage of using text files for data storage?

A disadvantage of text files is that it can be difficult to know where one record begins and ends.

26
New cards

What is an advantage of using arrays for data storage?

An advantage of arrays is that they can be more efficient and faster to search than text files.

27
New cards

When are text files useful for data storage?

Text files are useful for storing small amounts of data on secondary storage when the application is closed.

28
New cards

SQL

SQL (Structured Query Language) is a programming language used to interact with a Database Management System (DBMS).

29
New cards

SELECT (SQL)

The SELECT command in SQL is used to retrieve data (fields) from a database table. E.g. SELECT name, age

30
New cards

FROM (SQL)

The FROM command in SQL specifies the table(s) to retrieve data from.

31
New cards

WHERE (SQL)

The WHERE command in SQL filters the data based on a specified condition.

32
New cards

True or False? The '*' symbol is a wildcard in SQL.

True. The * symbol is called a wildcard in SQL and selects all fields in a table when used with SELECT.

33
New cards

SELECT * FROM Customers; What does this SQL command do?

This command selects all fields from the Customers table.

34
New cards

SELECT name, age FROM Customers WHERE age > 30; What does this SQL command do?

This command selects the name and age fields from the Customers table where the age is greater than 30.

35
New cards

True or False? To select all fields, you must list each field name after SELECT

False. Using SELECT * will select all fields in the table.

36
New cards

Give an example SQL command to select specific fields (country, population) from a table (world) with a condition (only countries that have a population less than 100,000.

Example: SELECT country, population FROM world WHERE population < 100000;

37
New cards

What does the FROM clause specify in an SQL SELECT statement?

The FROM clause specifies the table(s) to retrieve data from.

38
New cards

1D array

A 1D array is an ordered, static set of elements that can only store one data type. For example, a row in a table

39
New cards

2D array

A 2D array is an ordered, static set of elements that can only store one data type BUT adds another dimension. It can be visualised as a table with rows and columns.

40
New cards

Write Python code to create a 1D array named 'temp' with numbers 1-5.

temp = [1, 2, 3, 4, 5]

41
New cards

Write Python code to output element 2 of a 1D array named 'countries'.

print(countries[1])

42
New cards

Write Python code to modify element 3 in a 1D array named 'students' with the value "Rebecca".

students[2] = "Rebecca"

43
New cards

Write Python code to create a 2D array named 'scores'. Use values 1-9 to create 3 rows and 3 columns.

scores = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

44
New cards

True or False? 2D arrays can store different data types in the same array.

False. Like 1D arrays, 2D arrays can only store one data type.

45
New cards

What does zero-indexing mean for arrays?

Zero-indexing means that the indexes of an array start from 0, not 1.

46
New cards

Function

A function is a type of sub-program that performs a specific task and returns a value.

47
New cards

Procedure

A procedure is a type of sub-program that performs a specific task but does not return a value.

48
New cards

Parameter

A parameter is a value that is passed into a sub-program (function or procedure).

49
New cards

True or False? To use a function/procedure it must be 'called'.

True. To use a function or procedure, you 'call' it from the main program.

50
New cards

Global variable

A global variable is a variable declared at the outermost level of a program and can be accessed from any part of the program.

51
New cards

Local variable

A local variable is a variable declared within a specific scope, such as a function or code block, and can only be accessed within that scope.

52
New cards

What is the key difference between a function and a procedure?

A function returns a value, whereas a procedure does not return a value.

53
New cards

Write Python code to define a function named 'area' taking 2 parameters (length, width).

def area(length, width):

54
New cards

Write Python code to call a procedure named 'ageCheck', taking 1 parameter (21).

ageCheck(21)

55
New cards

Why are global variables generally discouraged in programming?

Global variables are generally discouraged because they can be accessed and modified from anywhere in the program, leading to potential bugs and hard-to-maintain code.

56
New cards

Why is random number generation used in programming?

Random number generation adds an element of unpredictability to a program.

57
New cards

True of False? Simulating the roll of a dice is an example of random number generation.

True. Examples include simulating dice rolls, selecting random questions, national lottery, cryptography.

58
New cards

How do you import the random module in Python?

To import the random module in Python, use: import random

59
New cards

random.randint(a, b)

The random.randint(a, b) function in Python generates a random integer between a and b, inclusive.

60
New cards

Write Python code to generate a random colour from 'red, 'blue', 'green' and 'yellow. Output the randomly chosen value.

import random colours = ["Red", "Green", "Blue", "Yellow"] random_colour = random.choice(colours) print(random_colour)

Explore top notes

note
Biodiversity: Evolution
Updated 1275d ago
0.0(0)
note
Photosynthesis
Updated 162d ago
0.0(0)
note
Spanish 4 Final Review
Updated 1208d ago
0.0(0)
note
Supraspinatus Syndrome
Updated 1147d ago
0.0(0)
note
Treaty of Versailles
Updated 927d ago
0.0(0)
note
Biodiversity: Evolution
Updated 1275d ago
0.0(0)
note
Photosynthesis
Updated 162d ago
0.0(0)
note
Spanish 4 Final Review
Updated 1208d ago
0.0(0)
note
Supraspinatus Syndrome
Updated 1147d ago
0.0(0)
note
Treaty of Versailles
Updated 927d ago
0.0(0)

Explore top flashcards

flashcards
Woody Plants exam 1+2 review
108
Updated 1071d ago
0.0(0)
flashcards
The Industrial Revolution
48
Updated 784d ago
0.0(0)
flashcards
duits examenidioom 26,27
26
Updated 1118d ago
0.0(0)
flashcards
GUMS M3.2
20
Updated 302d ago
0.0(0)
flashcards
frans: voc dépendance
62
Updated 365d ago
0.0(0)
flashcards
Däggdjur
41
Updated 374d ago
0.0(0)
flashcards
[PerDev] 2nd Quarter
103
Updated 1217d ago
0.0(0)
flashcards
Woody Plants exam 1+2 review
108
Updated 1071d ago
0.0(0)
flashcards
The Industrial Revolution
48
Updated 784d ago
0.0(0)
flashcards
duits examenidioom 26,27
26
Updated 1118d ago
0.0(0)
flashcards
GUMS M3.2
20
Updated 302d ago
0.0(0)
flashcards
frans: voc dépendance
62
Updated 365d ago
0.0(0)
flashcards
Däggdjur
41
Updated 374d ago
0.0(0)
flashcards
[PerDev] 2nd Quarter
103
Updated 1217d ago
0.0(0)