Quiz 2 Python - Minggu Cabaran Digital

Quiz 2 Python - Minggu Cabaran Digital

10 Qs

quiz-placeholder

Similar activities

Всемирная паутина

Всемирная паутина

1st Grade

15 Qs

Bài 4: Chèn đoạn video vào bài trình chiếu (Ôn tập 1)- lớp 5

Bài 4: Chèn đoạn video vào bài trình chiếu (Ôn tập 1)- lớp 5

5th Grade

10 Qs

DCN5511: Chapter 5 - 7

DCN5511: Chapter 5 - 7

University

15 Qs

Java: repetition control structure for & while

Java: repetition control structure for & while

10th - 12th Grade

10 Qs

EXÀMEN ANUAL DE COMUNICACIÒN

EXÀMEN ANUAL DE COMUNICACIÒN

4th Grade

13 Qs

Review III Unidad - 3er Grado

Review III Unidad - 3er Grado

1st - 3rd Grade

10 Qs

Aula 10 - Excel

Aula 10 - Excel

6th Grade

10 Qs

PREGUNTAS BÁSICAS SOBRE CONOCIMIENTO INFORMÁTICO

PREGUNTAS BÁSICAS SOBRE CONOCIMIENTO INFORMÁTICO

1st Grade - Professional Development

10 Qs

Quiz 2 Python - Minggu Cabaran Digital

Quiz 2 Python - Minggu Cabaran Digital

Assessment

Quiz

Computers

Practice Problem

Medium

Created by

Ammar Yasir

Used 4+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

  1. 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

  1. 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

  1. 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

  1. 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

  1. 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. 1. The variable x is assigned a list with three elements: [1, 2, 3].

  2. 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. 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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?