Python Programming

Python Programming

Assessment

Quiz

Hard

Created by

nithish singh

Used 1+ times

FREE Resource

Student preview

quiz-placeholder

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a correct syntax to output "Hello World" in Python?

display('Hello World')

console.log('Hello World')

output('Hello World')

print('Hello World')

Answer explanation

The correct syntax to output 'Hello World' in Python is print('Hello World'). This statement will display the text 'Hello World' on the console.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you include a comment in Python?
//This is a comment
/*This is a comment*/
#This is a comment

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create a function in Python?

def function_name():

function function_name{}

function_name[]:

function_name(){}

Answer explanation

To create a function in Python, use the 'def' keyword followed by the function name and parentheses. The correct choice is 'def function_name():'.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create a list in Python?

list = [1, 2, 3]

list: 1, 2, 3

list(1, 2, 3)

list = 1, 2, 3

Answer explanation

To create a list in Python, use the syntax list = [1, 2, 3]. This correctly initializes a list with the values 1, 2, and 3.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create a dictionary in Python?

dict = {1:'a', 2:'b', 3:'c'}

dict: 1='a', 2='b', 3='c'

dict(1='a', 2='b', 3='c')

dict = 1='a', 2='b', 3='c'

Answer explanation

To create a dictionary in Python, use the syntax dict = {1:'a', 2:'b', 3:'c'}. This assigns key-value pairs to the dictionary.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create a tuple in Python?

tuple = (1, 2, 3)

tuple: 1, 2, 3

tuple(1, 2, 3)

tuple = 1, 2, 3

Answer explanation

To create a tuple in Python, use the syntax tuple = (1, 2, 3). This choice correctly assigns the values 1, 2, and 3 to the tuple variable.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create a set in Python?

set = {1, 2, 3}

set: 1, 2, 3

set(1, 2, 3)

set = 1, 2, 3

Answer explanation

To create a set in Python, use the syntax: set = {1, 2, 3}. This correctly initializes a set with the values 1, 2, and 3.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?