
Mastering Python Basics
Authored by Dumbani Tunthuwa
Computers
12th Grade
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
15 questions
PTS Algoritma dan Pemrograman
Quiz
•
9th - 12th Grade
20 questions
Introducción a las bases de datos
Quiz
•
12th Grade
15 questions
SENATIC Parcial Guía 3_PseInt
Quiz
•
10th Grade - University
15 questions
Network Advantages and Disadvantages
Quiz
•
10th Grade - University
17 questions
Lección1 - JavaScript
Quiz
•
1st Grade - Professio...
17 questions
Shortcut keys
Quiz
•
7th - 12th Grade
20 questions
2324tx6
Quiz
•
9th - 12th Grade
25 questions
TIK01
Quiz
•
12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade