NEW
Font size
WorksheetsCCC 112 Introduction to Computer Programming 1
Total questions: 60
Worksheet time: 3600secs
Which characteristic of Python makes code execute immediately after it is written?
Object-oriented architecture
Interpreter system
Compiler optimization
Modular design
Python was first released publicly in which year?
1989
1991
1994
1998
Which Python feature eliminates the need to explicitly declare variable types?
Static typing
Type inference
Dynamic typing
Auto-casting
Which of the following is not a valid rule for Python identifiers?
They can start with a letter
They can contain numbers
They can start with a number
They can include underscores
In Python, indentation is used to:
Improve code execution time
Separate functions from variables
Define code blocks
Indicate comments
What happens when a user inputs data using input()?
The value is stored as an integer
The program automatically casts it
The program continues without waiting
The data is returned as a string
Which category does tuple belong to in Python’s built-in data types?
Binary type
Mapping type
Sequence type
Text type
Which function is used to explicitly convert a float string like "12.5" into a float?
cast()
float()
convert()
eval()
What will print("Hello" + 5) result in?
Hello5
5Hello
A TypeError
No output
The method used to convert a string to all lowercase letters is:
lowerCase()
lower()
tolower()
lowercase()
Which Python string feature allows extraction of specific portions of a string?
Index concatenation
String slicing
String partitioning
Lexical trimming
Which of the following is a numeric data type in Python?
frozenset
memoryview
float
range
The main purpose of creating global variables is to:
Improve loop speed
Restrict variable access
Use them inside and outside functions
Automatically optimize memory
Python was originally developed in which country?
USA
Germany
Netherlands
Canada
What does the replace() method return?
A modified copy of the string
A list of replaced characters
A boolean indicating success
The number of replaced characters
Which of the following represents a text data type in Python?
str
bytes
list
Which constructor removes decimals when converting?
str()
convert()
float()
int()
What is the correct way to declare a string variable?
text = Hello
text = "Hello"
string("Hello")
var text = 'Hello'
F-strings became available starting from which Python version?
2.7
3.0
3.4
3.6
Which characteristic of Python made it popular among scientists in the early days?
Built-in GUI library
Numerical computation and data analysis capabilities
Strong encryption support
Extensive mobile development tools
Which of the following best describes a list in Python?
A fixed-size ordered collection of items
A dynamic ordered collection that can store mixed data types
An unordered mutable collection with unique values
An immutable ordered collection of items
What will list("abc") return?
["abc"]
("a", "b", "c")
["a", "b", "c"]
{"a", "b", "c"}
Which method adds multiple items at once to a list?
insert()
append()
update()
extend()
Which of the following removes an element by index from a list?
remove()
pop()
delete()
clear()
What is the result of accessing my_list[-1]?
The second element
The first element
An error
The last element
Which statement about tuples is TRUE?
They can be extended using append().
They allow element reassignment.
They are immutable collections.
They cannot be nested.
What happens when a tuple is deleted using del my_tuple?
All elements are set to None
The reference to the tuple is removed
Only the last element is deleted
Tuple becomes empty but still exists
Which operation is valid for tuple concatenation?
tuple1 + tuple2
tuple1 | tuple2
tuple1.append(tuple2)
tuple1.extend(tuple2)
What is the main characteristic that distinguishes sets from lists?
Sets support indexing
Sets store only integers
Sets do not allow duplicates
Sets are ordered
Which expression creates an empty set?
{}
set()
[]
{None}
Which operation checks if an element exists in a set fastest?
Using index
Using in operator
Using pop()
Using count()
What will happen if you try to modify an element inside a set directly?
It is updated automatically
It raises a TypeError
The set converts to a list
Nothing happens
Which of the following creates a frozenset?
frozen({1,2,3})
frozenset([1,2,3])
set.frozen([1,2,3])
tuple.set()
What is the result of {1,2,3} & {3,4,5}?
{1,2,4,5}
{3}
{1,2}
{3,4,5}
Which Python collection stores data as key-value pairs?
List
Set
Tuple
Dictionary
Which of the following is NOT allowed as a dictionary key?
A string
A tuple
A list
An integer
What happens if a dictionary is created with duplicate keys?
It raises an error
All key-value pairs are stored
The last value overwrites the previous one
The first value is retained
Which method removes the last inserted key-value pair in a dictionary?
pop()
del
remove()
popitem()
Which statement about dictionary keys is TRUE?
Keys are case-sensitive
Keys can be lists
Keys must be unique only within nested dictionaries
Keys can be changed after creation
Which collection type is ordered and unchangeable?
List
Tuple
Set
Dictionary
Which statement is used to make decisions in Python?
for
if
loop
repeat
Which keyword is used when all previous conditions in an if-elif chain are False?
finally
unless
else
break
What does the elif keyword represent?
A separate if statement
Another condition after the first if
The end of a loop
A loop control instruction
Which logical operator returns True if at least one condition is True?
and
or
not
==
What is a nested if statement?
An if inside a loop
An if statement placed inside another if or else block
A loop inside an if
A function inside an if
Short-hand if (single-line if) is used when:
The condition and the action fit on one line
The condition is always false
The code block is very long
You need user input
Which operator is used to reverse a condition?
and
or
not
xor
Which loop repeats as long as a condition remains True?
for loop
while loop
do loop
until loop
The break statement is used to:
Skip to the next iteration
End the loop immediately
Restart the loop
Pause the program
The continue statement does what?
Ends the loop
Repeats the last instruction
Skips the current iteration and moves to the next
Stops the entire program
What kind of loop is best for iterating over sequences (lists, strings, etc.)?
switch loop
for loop
while loop
recursive loop
The range() function is used to:
Create infinite loops
Generate a sequence of numbers
Randomize values
Convert data types
The else clause in a loop executes when:
The loop ends normally without break
The loop has no condition
A continue is used
The loop runs only once
What is an infinite loop?
A loop that runs only twice
A loop without a break
A loop whose condition never becomes False
A loop that returns many outputs
Which form of control structure is used for decision-making?
loop structures
if-elif-else
functions
classes
What does a nested loop contain?
A loop inside another loop
A loop without conditions
Only if-else statements
A loop inside a function
A while-else block executes the else part when:
The loop breaks early
The loop condition becomes False naturally
The loop runs only once
The loop contains continue
Which condition is correctly written in Python?
if a = 10
if a equals 10
if a == 10
if (a = 10) then
Short-hand if-else (ternary operator) is written as:
if condition then value
value1 or value2
value_if_true if condition else value_if_false
if(condition){...}
Logical operators in Python include:
plus, minus, divide
if, elif, else
and, or, not
true, false, none
