
Mastering Python Basics

Quiz
•
Computers
•
12th Grade
•
Medium
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
Similar Resources on Wayground
20 questions
Python Basics (CodeHS)

Quiz
•
7th - 12th Grade
21 questions
Basic Python Console Operations

Quiz
•
10th Grade - University
20 questions
AIB_2Q

Quiz
•
12th Grade
20 questions
EXAMEN DE ANIVELACION

Quiz
•
12th Grade
20 questions
Python Basics Review (TSK)

Quiz
•
9th - 12th Grade
15 questions
CSE_CodeHS_intro_python_unit_3_5

Quiz
•
9th - 12th Grade
15 questions
G10 CS String Manipulation

Quiz
•
12th Grade
20 questions
Basic Python

Quiz
•
10th - 12th Grade
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade