wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Kuis Python Lanjutan kelas XII

Total questions: 10

Worksheet time: 8mins

Name
Class
Date
1.

Example:

X=1.0

Y=12.3

Z=-13.4

Diatas adalah contoh dari type data ....

a)

Integer

b)

Long Integer

c)

float

d)

char

e)

String

2.

Example: Vardemo1.py

x=y=z=50

print x

print y

print z

Berapakah hasil (output) dari kode program diatas ...

a)

50

05

50

b)

50

c)

50

50

05

d)

50

100

150

e)

50

50

50

3.

Secara umum, Komentar digunakan dalam bahasa pemrograman untuk mendeskripsikan program atau menyembunyikan beberapa bagian kode dari penerjemah. Komentar dalam Python dapat digunakan untuk menjelaskan kode program apa pun. Komentar juga dapat digunakan untuk menyembunyikan kode. Berikut adalah penulisan Komentar yang SALAH pada python adalah...

a)

# This is single line comment 

print "Hello Python"

b)

""" Penulisan Komentar lebih dari satu baris yaitu dengan menggunakan kutip dua 3 kali dan ditutup dengan kutip dua 3 kali juga """

c)

$Komentar dituliskan dengan kode $

d)

print("Hello World") #ini juga komentar

e)

# komentar bisa berisi spesial karakter !@#$%^&\*(),./;'[]\

4.

Example:

A=2+5j

B=-3+4j

C=-6j

Diatas adalah contoh type data ....

a)

Int

b)

Float

c)

Str

d)

Complex

e)

Bool

5.

Example:  datatypesdemo.py

a=10 

b=“Python" 

c = 10.5

d=2.14j

print("Data type of Variable a :",type(a))  

print("Data type of Variable b :",type(b))  

print("Data type of Variable c :",type(c))

print("Data type of Variable d :",type(d))

Dari kode diatas, apakah outputnya ....

a)

Datatype of Variable a : <class ‘a’>

Datatype of Variable b : <class ‘b’>

Datatype of Variable c : <class ‘c’>

Datatype of Variable d : <class ‘d’>

b)

Datatype of Variable a : <class ‘int’>

Datatype of Variable b : <class ‘str’>

Datatype of Variable c : <class ‘float’>

Datatype of Variable d : <class ‘complex’>

c)

TypeData of Variable a : <class ‘int’>

TypeData of Variable b : <class ‘str’>

TypeData of Variable c : <class ‘float’>

TypeData of Variable d : <class ‘complex’>

d)

Datatype of Variable a : <class ‘int’>

Datatype of Variable b : <class ‘int>

Datatype of Variable c : <class ‘int’>

Datatype of Variable d : <class ‘int’>

e)

Datatype of Variable a : <‘int’>

Datatype of Variable b : <‘str’>

Datatype of Variable c : <‘float’>

Datatype of Variable d : <]‘complex’>

6.

eg:

a=20;

b=10

then a % b= .....

a)

0

b)

1

c)

2

d)

3

e)

4

7.

a=24;

b=7

then a // b = .....

a)

0

b)

1

c)

2

d)

3

e)

4

8.

Berikut contoh kode program dari operator Gabungan Assignment Python:

x = 10

x += 5

print('x += 5  :',x)

  

x = 10

x /= 5

print('x /= 5  :',x)

  

x = 10

x **= 5

print('x **= 5 :',x)

  

x = 10

x <<= 2

print('x <<= 2 :',x)

Dari kode-kode diatas, bagaimanakah outputnya .....

a)

x += 5  : 15

x /= 5  : 2.0

x **= 5 : 100000

x <<= 2 : 40

b)

x += 5  : 1

x /= 5  : 2.0

x **= 5 : 30

x <<= 2 : 40

c)

x += 5  : 4

x /= 5  : 2.0

x **= 5 : 100000

x <<= 2 : 40

d)

x += 5  : 50

x /= 5  : 2.0

x **= 5 : 100

x <<= 2 : 40

e)

x += 5  : 1

x /= 5  : 2

x **= 5 : 3

x <<= 2 : 4

9.

Seperti bahasa pemrograman lainnya, pengindeksan string Python dimulai dari 0. Misalnya, string "HELLO" diindeks seperti yang ditunjukkan pada gambar di bawah ini.

str="HELLO"

Untuk str[2], maka output yang akan tampil adalah = ...

a)

H

b)

E

c)

L

d)

L

e)

O

10.

str1 = "Python is a programming language"

str2 = str1.split()

print(str1);print(str2)

Dari kode diatas, bagaimanakah output yang akan tampil ....

a)

Python is a programming language

b)

Python, is, a, programming, language.

c)

Python is a programming language

['Python', 'is', 'a', 'programming', 'language']

d)

Java is a programming language

['Java', 'is', 'a', 'programming', 'language']

e)

Python is a programming language

Python, is, a, programming, language.