Mastering Python Basics

Mastering Python Basics

12th Grade

20 Qs

quiz-placeholder

Similar activities

Python Basics-02

Python Basics-02

9th - 12th Grade

21 Qs

CodeHS Python Unit 3 Quiz Review

CodeHS Python Unit 3 Quiz Review

9th - 12th Grade

20 Qs

GCSE Computer Science - Programming Keywords

GCSE Computer Science - Programming Keywords

9th - 12th Grade

15 Qs

Python-Basic

Python-Basic

3rd Grade - University

15 Qs

ASK F2 -KOD ARAHAN (PYTHON)

ASK F2 -KOD ARAHAN (PYTHON)

1st Grade - University

15 Qs

IDT Unit 2 Review (practice for Test 2)

IDT Unit 2 Review (practice for Test 2)

8th - 12th Grade

20 Qs

Arrays in Java

Arrays in Java

9th - 12th Grade

20 Qs

การเขียนโปรแกรมภาษา python ม.5 ภาคเรียนที่ 2 ปีการศึกษา 2561

การเขียนโปรแกรมภาษา python ม.5 ภาคเรียนที่ 2 ปีการศึกษา 2561

10th - 12th Grade

20 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?

Discover more resources for Computers