Mastering Python Basics

Mastering Python Basics

12th Grade

20 Qs

quiz-placeholder

Similar activities

quiz dasar python

quiz dasar python

1st Grade - University

20 Qs

Intro to Python Vocabulary

Intro to Python Vocabulary

7th - 12th Grade

20 Qs

PYTHON BASIC 1 - 5

PYTHON BASIC 1 - 5

12th Grade

20 Qs

Array

Array

10th - 12th Grade

15 Qs

CodeHS - Intro to Python - Basics and Console Interaction

CodeHS - Intro to Python - Basics and Console Interaction

9th Grade - Professional Development

20 Qs

SIS_Computer Science

SIS_Computer Science

10th Grade - University

18 Qs

INTRODUCITON TO PYTHON

INTRODUCITON TO PYTHON

11th - 12th Grade

20 Qs

15 days of code quiz 2

15 days of code quiz 2

11th Grade - Professional Development

22 Qs

Mastering Python Basics

Mastering Python Basics

Assessment

Quiz

Computers

12th Grade

Medium

Created by

Dumbani Tunthuwa

Used 1+ times

FREE Resource

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to declare a variable in Python?

var x: int = 5

x = 5

x := 5

let x = 5

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you assign a value to a variable in Python?

Assign values using the '->' operator.

Variables are assigned values by enclosing them in parentheses.

Use the '=' operator to assign a value to a variable.

Use the '==' operator to assign a value to a variable.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Define a function in Python and provide an example of how to call it.

def greet(name): return f'Hello, {name}!' # Example of calling the function: print(greet('Alice'))

greet(name): print('Greetings, ' + name)

def greet(): return 'Hello!'

def hello(name): return 'Hi, ' + name

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code: print('Hello' + ' World')?

Hello World

Hello, World

Hello World!

HelloWorld

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you access the first character of a string in Python?

s[1]

s.first()

s.get(0)

s[0]

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is string slicing and how is it used in Python?

String slicing is used to convert a string to uppercase in Python.

String slicing allows you to replace characters in a string directly in Python.

String slicing is a method to concatenate two strings in Python.

String slicing is a method to extract parts of a string using the syntax string[start:end:step] in Python.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain type casting in Python with an example.

Example: num_str = '123'; num_int = int(num_str); # num_int is now an integer 123

Example: num_list = [1, 2, 3]; num_str = str(num_list); # num_str is now a string '[1, 2, 3]'

Example: num_float = 123.45; num_str = str(num_float); # num_str is now a string '123.45'

Example: num_bool = True; num_int = int(num_bool); # num_int is now an integer 1

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?