Quiz 2 Python - Minggu Cabaran Digital
Quiz
•
Computers
•
•
Practice Problem
•
Medium
Ammar Yasir
Used 4+ times
FREE Resource
Enhance your content in a minute
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
x = 10
y = 2
print(x ** y)
20
5
100
12
Answer explanation
The ** operator in Python is used to calculate the power of a number. in this code, ' 10 ' raised to the power of ' 2 ' is ' 10 * 10 ', which equals 100. Therefore, the output of the print() function will be ' 100 '.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What function is used to convert a data type from string to integer?
What function is used to convert a data type from string to integer?
int()
str()
float()
bool()
Answer explanation
The int() function converts a string or another number type to an integer.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you get the last element in a list my_list?
How do you get the last element in a list my_list?
my_list[0]
my_list[-1]
my_list[len(my_list)]
my_list[last]
Answer explanation
In Python, you can access elements in a list using index numbers. The first element in a list has an index of 0, the second element has an index of 1, and so on. To access the last element in a list, you can use the index -1. This is because the index -1 refers to the last element in the list, -2 refers to the second-to-last element, and so on.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct way to import the ' math ' module in Python?
What is the correct way to import the ' math ' module in Python?
import math
import Math
include math
using math
Answer explanation
The ' import ' statement is used to import the math module. Also, In Python, module names are typically written in lowercase letters, with words separated by underscores if necessary.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the ' // ' operator mean in Python?
What does the ' // ' operator mean in Python?
Regular division
Division with remainder
Integer (floor) division
Modulus division
Answer explanation
The // operator performs integer division and returns the largest integer less than or equal to the division result.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
What is the output of the following code?
a = [1, 2, 3]
b = a
b.append(4)
print(a)
[1, 2, 3]
[1, 2, 3, 4]
Error
[1, 2]
Answer explanation
In Python, assigning b = a means that b refers to the same list object as a. Thus, any modification to b also affects a.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
x = [1, 2, 3]
x.append([4, 5])
print(len(x))
3
4
5
6
Answer explanation
Here's an explanation of what the code does:
1. The variable x is assigned a list with three elements: [1, 2, 3].
2. The append() method is called on the list referenced by x, adding a new list [4, 5] to the end of the list.
3. The len() function is called on the list referenced by x, which returns the number of elements in the list.
Since the list [4, 5] is a single element in the list x, the length of the list x is 4. Therefore, the output of the code is 4.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Word 2016
Quiz
•
10th Grade
10 questions
C# lesson10
Quiz
•
1st - 10th Grade
15 questions
Excel - basic
Quiz
•
9th Grade
15 questions
حاسب 2
Quiz
•
10th Grade
13 questions
8 - Организация работы в AutoCAD
Quiz
•
University
10 questions
Teknik Pemikiran Komputasional
Quiz
•
2nd - 3rd Grade
10 questions
Sistem Mikrowave TJKT
Quiz
•
10th Grade
15 questions
S2 Databases
Quiz
•
2nd Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
Discover more resources for Computers
10 questions
Module 2 Vocab
Quiz
•
5th Grade
18 questions
[AP CSP] JavaScript Programming Lesson 2025-2026
Lesson
•
9th - 12th Grade
57 questions
[AP CSP] Unit 5 Review: Internet & Cybersecurity
Quiz
•
9th - 12th Grade
10 questions
Exploring Digital Citizenship Essentials
Interactive video
•
6th - 10th Grade
20 questions
CompTIA Network+ - Ports and Protocols
Quiz
•
University
15 questions
Google Sheets
Quiz
•
7th - 8th Grade
10 questions
Introduction to Coding
Interactive video
•
3rd - 6th Grade
