wayground logo

Lembar Kerja Gratis yang Dapat Dicetak

Ukuran huruf

S
M
L
XL
Lembar kerja

Python Basic Final

Total soal: 90

Worksheet time: 43hrs 4mins

Nama
Kelas
Tanggal
1.

What is programming, and why is it important for students to learn about it in today's world?

a)

a) Programming is a type of video game.

b)

b) Programming is the process of instructing a computer to perform tasks, and it's important for students to learn because it empowers them to solve problems and automate tasks.

c)

c) Programming is a form of storytelling.

d)

d) Programming is only relevant to professional software developers.


2.

How would you explain the basic syntax of Python to a beginner, and why is Python often recommended as a first programming language for students?

a)

a) Python is recommended for students because it has a complex syntax.

b)

b) Python's syntax is difficult for beginners to grasp.

c)

c) Python is recommended for its simple and readable syntax, making it accessible for beginners.

d)

d) Python is recommended because it's the only language available for students.


3.

What are some common use cases for input/output functions in Python, and how can students effectively use these functions to interact with their programs?

a)

a) Input/output functions are only used by professional programmers.

b)

b) Input/output functions in Python are used for making coffee.

c)

c) Input/output functions are used to read and write data to/from files, and to interact with users through the command line or graphical user interfaces.

d)

d) Input/output functions in Python are used for gaming purposes only.


4.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
5.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
6.
What symbol is used in python to assign values to a variable?
a)

=

b)

+

c)

*

d)

%

7.

What is a input?

a)

A function that allows us to ask the user to enter some data.

b)

To plug in something.

c)

Data displayed on a screen.

d)

A function

8.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
9.

What is the proper syntax for Python comments?

a)

<!-- Python comment -->

b)

<comment> Python comment <comment>

c)

# Python Comment

d)

/* Python Comment */

10.

What will be printed out?

x = 10

y = 10

print(x != y)

a)

True

b)

False

11.

What will be printed out?

x = 5

y = 3

print(x == y)

a)

True

b)

False

12.

The result of 10%2 will be :

a)

1

b)

5

c)

2

d)

0

13.

Click all comparison operators

a)

!=

b)

*=

c)

==

d)

>=

e)

=

14.

Click all arithmetic operators

a)

**

b)

=

c)

+=

d)

-

e)

%

15.

Can you add 2.6 to "Cat"?

a)

Yes! I'll demonstrate on the board!

b)

No. You're probably nuts for thinking this.

16.

Empty curly braces in an assignment statement will create which type of data structure?

(s = {})

a)

List

b)

Dictionary

c)

Stack

d)

Set

17.

Which data structure stores key/value pairs?

a)

Sets

b)

Stacks

c)

Lists

d)

Dictionaries

18.

Each key/value pair in a dictionary is separated by this symbol:

a)

/

b)

,

c)

:

d)

;

19.

Choose all of the following which are built in data types in Python

a)

dict

b)

list

c)

set

d)

tuple

20.

A dictionary is an example of a sequence ...

a)

True

b)

False

21.

Which code will set the "Year" from 2006 to 2008?

birthday = {

"Month": "January",

"Day": "01",

"Year":2006

}

__________________________________

OUTPUT: 2008

a)

birthday["Year"]=2008

b)

birthday[Year]=2008

c)

birthday [2008]

d)

birthday[2006]=2008

22.

What will this code do?

birthday = {

"Month": "January",

"Day": "01",

"Year":2006

}

for x in birthday:

print(x)

a)

Prints all the key names in the dictionary

b)

print all the key and value pairs is the dictionary

23.

The dictionary dnry is initialized as follows:

dnry = {"L": 8, "W": 5, "H": 11}

Which statement will give you the value 5?

a)

dnry[1]

b)

dnry["W"]

c)

dnry["5"]

d)

dnry[2]

24.

A collection of modules and packages that can be imported into a program is called a __________.

a)

class

b)

documentation

c)

library

d)

function

25.

What is the extension of python library modules?

a)

.mod

b)

.lib

c)

.code

d)

.py

26.

In python which is the correct method to load a module math?

a)

include math

b)

import math

c)

#include<math.h>

d)

using math

27.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

28.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

29.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

30.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]

31.

For tuples and list which is correct?

a)

List and tuples both are mutable.

b)

List is mutable whereas tuples are immutable.

c)

List and tuples both are immutable.

d)

List is immutable whereas tuples are mutable

32.

Which is a correctly declared tuple?

a)

a = ("orange", "yellow", "red")

b)

a = "orange", "yellow", "red"

c)

a = ["orange", "yellow", "red"]

d)

a = "orangeyellowred"

33.

Can you have an empty tuple z = () or an empty string w = []?

a)

yes

b)

no

34.

If L1=[2,4,8,16], L2=[32,64] what is L1+L2

a)

[2,4,8,16,32,64]

b)

[2,4,8,16][32,64]

c)

[2,4,8,16],[32,64]

d)

None of the above

35.

Suppose list1 is [1, 3, 2]

What is list1 * 2 ?

a)

[2, 6, 4].

b)

[1, 3, 2, 1, 3]

c)

[1, 3, 2, 1, 3, 2]

d)

[1, 3, 2, 3, 2, 1]

36.

Match the following

a)

Unable to change.

1.

Immutable

b)

A particular way of organizing data in our programs.

2.

Data Structure

c)

A heterogenous, immutable data type that stores an ordered sequence of things.

3.

Tuple

d)

A heterogenous, mutable data type that stores an ordered sequence of things.

4.

List

e)

Add a particular item to the end of a list.

5.

append()

37.

Which of the following keywords marks the begining of the function block?

a)

Func

b)

define

c)

def

d)

function

38.

Which of the following items are present in the function header?

a)

Function name only

b)

Both function name and parameter list

c)

parameter list only

d)

Return value

39.

What term is used to describe data passed into/out of a program?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

40.

Consider the line of code:

Label('Go Team', 200, 100)

What is the Label?

a)

argument

b)

parameter

c)

function name

41.

Rewrite this line of code correctly!

(a)  

42.

When defining a function, the definition must occur before it is called.

a)

true

b)

false

43.

What does the following code output?

a)

11, 9

b)

16, 16

c)

None, None

d)

225, 117

44.
Look at this code, how many times will it loop?
a)
50
b)
90
c)
0
d)
4
45.
What is another way of writing the following code? 
Score = Score + 1 
a)
Score.add(1)
b)
score + 1
c)
Score + Score
d)
Score += 1
46.
What are the two main types of loops that we have learned about in Python?
a)
IF Function & Variables
b)
FOR and WHILE Loops
c)
Forever and Fixed Loop
d)
Data Types and Numbers
47.
What is the word used to describe repetition in programming?
a)
Sequence
b)
Selection
c)
Iteration
d)
Coding
48.

The program above

a)

prints all the odd numbers between 1 and 20

b)

prints all even numbers between 1 and 20

c)

print all the odd numbers between 1 and 21

d)

prints all the even numbers between 1 and 21

49.

for i in 100 :

print ( i )

a)

Syntax error

b)

prints numbers 0 to 100

c)

prints numbers 1 to 100

d)

prints numbers 0 to 99

e)

prints numbers 1 to 99

50.

Repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body.

a)

while loop

b)

for loop

c)

nested loop

d)

infinite loop

51.

Repeats instructions multiple times and automatically updates the counting number used in the loop.

a)

while loop

b)

for loop

c)

nested loop

d)

infinite loop

52.
Why is iteration important?
a)
It determines the order in which instructions are carried out
b)
It allows code to be simplified by removing duplicated steps
c)
It allows multiple paths through a program
53.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
54.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
55.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
56.
For strings, the + operator represents 
a)
Concatenation
b)
Addition
c)
Appending
d)
Recantation 
57.

What data type uses quotation marks?
" "

a)

String

b)

Integer

c)

Float

d)

Number

58.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
59.

Please select all floating point numbers:

a)

1.444

b)

34567

c)

777.980

d)

32.0

e)

21

60.

What data type would store the value: True

a)

Boolean

b)

String

c)

Integer

d)

Float

61.

What is the data type of the following: "89 / 90"

a)

String

b)

Integer

c)

Float

d)

Number

62.

A variable in Pyton is ​ (a)  

Pilihlah dari kata-kata di bawah ini
a named location in memory used to store data
A function that performs a specific task
A keyword that defines loop
A way to comment out code
63.

Which code will display the multiplication table of 3?

a)

b)

c)

d)

64.

Which code will print only odd numbers ?

a)

b)

c)

d)

65.

What is the data structure of days based on the following code:

days = ["Sunday","Monday","Tuesday"]

a)

List

b)

String

c)

Numeric

d)

Tuple

66.

What is this symbol called? (*)

a)

star

b)

asterisk

c)

apostrophe

d)

multiplication

67.
What is an index?
a)
An ordered set; that is, a set of values where each value is identified by an integer index.
b)
A statement that calls a method.
c)
Something a variable can refer to. For now, you can use “object” and “value” interchangeably.
d)
An integer value used to select an item in a sequence, such as a character in a string.
68.

What is a comment in Python?

a)
  • A note written in the program to help people understand the code. The computer ignores it.

b)

Solving a math problem in the program to get one final answer.

c)

A special word in Python that already has a job and cannot be used as a name.

d)

A symbol like + or * that tells the computer to do math.

69.

To add an item to the end of a list, what command can we use?

a)

append()

b)

insert()

c)

split()

d)

remove()

70.

Comparing a dictionary to Python to a dictionary for words, ____________ is each word we look up_______ is definition of the word

a)

value, key

b)

key, attribute

c)

method, value

d)

key, value

71.

thisList = ["square", "circle", "triangle", "octagon"]

print(thisList[3])

a)

octagon

b)

triangle

c)

circle

d)

square

72.

Given the following dictionary, which code can add `Zip` as `10001`?

a)

dictionary["Zip"] = "10001"

b)

dictionary.update({"Zip": "10001"})

c)

dictionary[0] = "Zip:10001"

d)

dictionary[0] = ("Zip": "10001")

73.

What will be printed to the screen when the following program is run?

my_list = [5, 10, 30, 40]

print(my_list[3])

a)

5

b)

10

c)

30

d)

40

74.

Which data type is used to store whole numbers in Python?

a)

float

b)

str

c)

bool

d)

int

75.

What is the syntax to check if two values are not equal in Python?

a)

!==

b)

!=

c)

==

d)

<>

76.

What is the syntax to check if a value is greater than or equal to another value in Python?

a)

>

b)

>=

c)

<

d)

==

77.

What is the syntax to check if a value is less than or equal to another value in Python?

a)

<=

b)

>=

c)

==

d)

>

78.

What is the syntax to check if a value is greater than another value in Python?

a)

a < b

b)

a > b

c)

a >= b

d)

a == b

79.

Which of the following correctly stores 'price' as a decimal number?

a)

price = int ( input ("Price: ")

b)

price = str( input ("Price: ")

c)

price = float ( input ("Price: ")

d)

price = input ("Price: ")

80.

Which is the correct way to declare 3 variables, 'a' , 'b', 'c' to 1?

a)

a = b = c = 1

b)

a,b,c = 1

c)

a == b

b == c

c == 1

d)

abc = 1

81.

Which of the following brackets are used for list?

a)

{ }

b)

[ ]

c)

( )

d)

| |

82.

Which line has an error?

a)

19

b)

21

c)

23

d)

18

83.

Which of the following will print 10?

a)

print(7 + 3)

b)

print("6 + 4")

c)

print("5" + "5")

d)

print("0" + 10)

84.

_________________ is a decimal number.

a)

Integer

b)

Variable

c)

String

d)

Float

85.
What does an operator do in Python code?
a)

A special symbol that represents computations like addition, multiplication, or string concatenation.

b)

A portion of the code that is able to perform a special action

c)

A section of code that represents a command or action.

d)

A basic units of data, like a number or string, that a program manipulates.

86.

The following code is an example of which data type in Python:

x = [ 1, 2, 3]

a)

Array

b)

List

c)

Tuple

d)

Dictionary

87.

Spaces are not important in Python.

a)

True

b)

False

88.

Which of the following are valid Python arithmetic operators?

a)

$

b)

**

c)

//

d)

%

89.

How do you declare and initialize a variable with the integer data type in Python?

​ (a)  

Pilihlah dari kata-kata di bawah ini
number = int(input("Enter a number: "))
3etNum = 5
number = input("Enter a number: "))
number = 5.0
90.

What is the output?

a)

My

b)

Exam

c)

Practice

d)

Cloud

e)

Tests