stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
COSC1112 Flashcards | StudBud
Explore
/
COSC1112
COSC1112
13 terms
·
StudBud Administration
·
28 plays
This covers our entire COSC111 revision
Flashcards
13 cards
F
Practice quiz
P
Host live
L
Questions
13
Answers
1
What will the following code output?
3
1
4
2
2
What is the output of the following code?
[1, 2, 3]
4
[1, 2, 3, 4]
None
3
Which of the following creates a dictionary in Python?
my_dict = {"name": "Alice", "age": 25}
my_dict = {1, 2, 3}
my_dict = [1: "apple", 2: "banana"]
my_dict = ("name": "Alice", "age": 25)
4
What does the following function do?
Multiplies two numbers
Takes an input and prints it
Prints "Hello!"
Returns "Hello!"
5
Which of the following will correctly call a function named
greet
?
greet[]
greet{}
greet()
call greet
6
Which of the following is the correct way to access the value 'banana' in this dictionary?
fruits["banana"]
fruits(2)
fruits[2]
fruits["orange"]
7
Which of these is the correct way to create a list?
my_list = <1, 2, 3>
my_list = {1, 2, 3}
my_list = [1, 2, 3]
my_list = (1, 2, 3)
8
What is the correct syntax for defining a function in Python?
function greet():
def greet():
greet def():
def greet:
9
What will be the result of this code?
a + b
23
Error
5
10
How do you add an item to a list in Python?
my_list.insert(5)
my_list.append(5)
my_list.update(5)
my_list.add(5)
11
What is a Python list used for?
Performing mathematical operations
Iterating over values
Storing one item in a variable
Storing multiple items in one variable
12
What will the following code output?
25
name
Alice
Error
13
What is a Python dictionary used for?
Storing multiple values in an ordered sequence
Repeating code multiple times
Storing items as key-value pairs
Sorting a list of values