Font size
WorksheetsPre-Test Praktikum
Total questions: 50
Worksheet time: 24mins
Yang manakah yang merupakan code untuk menambahkan comment dalam python?
//
#
<comment>!
/*
Apakah python perlu menggunakan tanda titik koma (;) pada akhir codenya?
Ya
Tidak
Yang manakah file python?
.ptn
.pyt
.pytn
.py
Type data yang menunjukan sebuah bilangan desimal adalah ...
string
float
int
bool
What will be the output?
name = "Dave"
print (name)
Dave
'Dave'
name
(name)
If you want to create an empty list called colours in Python, which of the following is correct?
colours = [ ]
colours = ( )
colours = { }
colours = <>
What will the output be from the following code?
print(3+4)
3+4
7
SyntaxError
print(3+4)
What would this print?
What will the output be from the following Python code?
Print("Hello world!")
NameError
Hello world!
"Hello world"
Print(Hello world!)
What will the output be from the following Python code?
print(Hello world!)
Hello world!
SyntaxError
Hello world
print(Hello world!)
What is the Python built-in function to converts a number to a string?
str()
int()
parseInt()
convert
Which of these is correct Python conditional statement?
IF answer == "Yes":
if answer == "Yes"
if answer == "Yes":
if answer = "yes":
What is a Count-Controlled loop?
for loop
while loop
A count controlled loop will..
Repeat code until a condition is met
Repeat code a specific amount of times
Repeat code a random amount of times
None of the above
Which of these is NOT a loop in python?
for loop
while loop
nested loop
if loop
Which of these operators means EQUAL TO?
'='
'=>'
'<='
'=='
What is a list in python?
A collection of variables
A collection of items assigned to a single variable
A statement that cant be changed
A Christmas list
Which of these codes is correct for creating a list of numbers?
num = ('10','29','37','109')
num = ['10','29','37','109']
num == ('10','29','37','109')
num = ['10 29 37 109']
What is the index number for 'Spain'?
['England','Brazil','Spain','France']
0
1
2
3
How do i remove something from a list?
variable.append()
variable.delete()
variable.remove()
variable=(new variable)
What is used to separate elements in a list?
Bracket
Comma
Full Stop
Space
variable.sort() will do what?
Sort the list into alphabetical order
Sort the list into reverse order
Create a new list
Error
Which of the following is used in Python to calculate ten squared?
1. Examples for list data type
[1,2,3,4,5]
['S','H','R','U','T','H','I']
{1:"a",2:"b",3:"c",7:"d"}
('A','B','C','D')
What’s the main difference between Python lists and tuples?
Lists can hold any data type and tuples can only contain int and str objects.
Lists are immutable and tuples are mutable.
Lists are mutable and tuples are immutable.
Lists are faster and tuples are slower.
Check Your Answer »
kata = "SWEforML"
print(kata[-4:])
forM
SWEf
orML
Efor
Apa output dari kode program berikut?
print("Hello" + str(2) + "world!")
Hello world! Hello world!
Hello Hello world! world!
Hello2world!
SyntaxError
perhatikan program dibawah ini :
list1 = ['fisika', 'kimia', 1993, 2017]
print ("list1[0]: ", list1[0])
jika di run akan menghasilkan...
list1[0]: fisika
list1[0]: kimia
list1[0]: 1993
list1[0]: 2017
Simbol yang digunakan pada tipe data Tuple adalah...
[ ]
( )
{ }
{ } dan [ ]
Jika kita ingin menulis lebih dari satu statement dalam satu baris pada bahasa Python, maka kita harus memisahkan antar statementnya dengan menggunakan tanda
Pagar
Spasi
Koma
Titik-Koma
Petik
dictionary dapat dibuat dengan menggunakan tanda ...
kurung siku / [ ]
kurung kurawal / { }
kurung < >
kurung ( )
Berdasarkan kode berikut:
bil1 = 5
bil2 = bil1 % 2
bil1 *= bil2
print(bil1)
0
1
5
10
Untuk kode di bawah ini, Python akan menampilkan pesan:
bilangan = (5 % 3 ** 2) + (3 + 2 * 2) * (4 - 2)
print(bilangan)
28
26
19
30
for a in range(4)
print(a)
outputnya adalah
1 2 3 4
0 1 2 3
4 4 4 4
1
2
3
4
0
1
2
3
