NEW
Font size
WorksheetsPYTHON BASIC 1 - 5
Total questions: 20
Worksheet time: 10mins
What is Python ?
Python is text-based programming
Python is a kind of snake
Python is block-based programming
Python is human language
How do you insert COMMENTS in Python code?
/*This is a comment*/
#This is a comment
//This is a comment
Any of the Above
What is a correct syntax to return the first character in a string?
x = "Hello"[0]
x = "Hello".sub(0, 1)
x = sub("Hello", 0, 1)
x = first("Hello")
What is the output for −
'Hello world' [1:2]
Hello
e
world
Syntax error
How do you define (assign) variables?
var="String"
func==Hello
var : 123
word= Hello
What is the word (command) used to display numbers and text on the screen?
Input
Output
Command
What symbol is used in python to assign values to a variable?
:
*
=
==
Data type for a whole number (nombor bulat)
Float
Boolean
Integer
String
A Python data type that holds positive and negative whole numbers?
String
int
str
input
In Python, a variable must be declared before it is assigned a value:
False
True
Which of the following statements assigns the value 100 to the variable x in Python:
let x = 100
x = 100
x << 100
x ← 100
x := 100
What is the output of the following code:
x = 5
y = "John"
print(x + y)
5 John
x John
Error because x and y are from two different type of data
Error because 5 does not have quotation mark
Create a variable named carname and assign the value Proton to it.
Proton = carname
Proton = "carname"
carname = "Proton"
carname = 'Proton"
carname = Proton
Create a variable named x and assign the value 50 to it. The value, 50 is in string type.
x = 50
50 = "x"
x = "50"
x (50)
What is the output of the following code?
a = "I am cute
print(a[3)
c
m
space
cute
What is the output of the following code:
b = "Programming is fun!"
print(b[2:7)
ogram
ogramm
gram
gramm
a = "Good Morning!"
print(len(a))
13
12
11
14
a = "Hello, World!"
print(a.lower())
hello, World!
HELLO, WORLD!
hello, world!
Error
a = "Hello, World!"
print(a.replace("H", "J"))
Jello, World!
jello, World!
JELLO, WORLD!
jello, world!
What is the output of the following code:
age = 36
txt = "My name is John, I am " + age
print(txt)
My name is John, I am
My name is John, I am 36
Error
