Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python L3 Concepts

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

What is Tkinter?

a)

A python based programming language used for creating GUI applications

b)

A toolkit that translates python into HTML for creating visual web interfaces

c)

A text editor built into the operating system that we can modify

d)

A binding that allows us to use Tk, a toolkit written in C, to create GUI applications with python

2.

The ____ of a tk button is the function that runs when the button is clicked.

a)

object

b)

command

c)

control

d)

text

3.

A ____ is a graphical component of a tkinter GUI with a specific purpose.

a)

gadget

b)

box

c)

frame

d)

widget

4.

Why would we typically use a lambda function?

a)

To define a named class method

b)

To create a function that takes in no arguments

c)

To create a function from changing values and save it to use later

d)

To replace a conditional statement in our code

5.

The command of a button in tkinter is

a)

The text displayed on the button

b)

The function that runs when the button is pressed

c)

Always a lambda function

d)

Always a defined class method

6.

How do you access the text field of a tkinter button?

a)

text = mybutton["text"]

b)

text = mybutton.getLabel()

c)

text = mybutton.getText()

d)

text = mybutton.text.get()

7.

Which tkinter class does our Application inherit from?

a)

tk.Object

b)

tk.Frame

c)

tk.Text

d)

tk.Label

8.

How do we place a button in an Application using a grid layout?

a)

button.place(r=row, c=column)

b)

button.set(row=r, column=c)

c)

button.show(row=r, column=c)

d)

button.grid(row=r, column=c)

9.

What function is used to remove a widget from an application?

a)

.remove()

b)

.delete()

c)

.active()

d)

.destroy()

10.

How would we create a function that returns five times the input value?

a)

y = lambda x, x = x * 5

b)

y = x * 5

c)

lambda = x * 5

d)

y = lambda x: x * 5

11.

The ____ is the encrypted text of a message.

a)

plaintext

b)

ciphertext

c)

deciphertext

d)

cryptext

12.

A shift cipher disguises a message by :

a)

Replacing each letter by another letter in a randomly generated sequence of letters

b)

Replacing each letter by a number in a code book that was agreed upon earlier

c)

Replacing each letter by another letter in the alphabet shifted by a set amount called a key

d)

Replacing each word by another sequence of letters according to a set of rules

13.

The modulo operator:

a)

performs repeated addition

b)

performs division and returns the remainder

c)

performs division and returns the quotient

d)

gives the percent value of a number

14.

When we load information about an object from a .json file:

a)

It is a Python object, we can use it right away

b)

It is a Python dictionary, and we need to set the object's variables equal to the values of the dictionary

c)

It is a Python string, and we need to parse information about the object's variables from the string before we can use it

d)

We can't save data about objects in Python to a .json file

15.

Why do we use modulo to implement a shift cipher?

a)

Because adding the key to a letter's value can result in a number greater than 25, and we need to wrap the result back to 0

b)

Because the modulo function performs the conversion between the letter and its ASCII numerical representation

c)

We don't need to use modulo

d)

Because modulo turns the decimal result of division into a fraction that we can use

16.

What is recursion?

a)

It is another name for a loop

b)

It is a data structure, like a dictionary, that we can use to store information

c)

It is a principle of object oriented computer programming that allows us to borrow methods and attributes from other classes

d)

It is a method of repeatedly applying the same steps to smaller and smaller parts of a larger problem

17.

How do we implement recursion?

a)

By creating a new variable of type recursion

b)

By using many nested for-loops

c)

By making copies of our program to run in different locations

d)

By calling a function from within itself

18.

Why is it important to consider the termination condition when using recursion?

a)

The termination condition is a error that we can run into when we implement recursion

b)

The termination condition tells the program when it should stop running, without it the program would recurse forever

c)

The termination condition is an optional part of recursion that can change the outcome of the program

d)

The termination condition prevents us from implementing recursion, so we have to remove it from our program

19.

What is a test user and why do we need to add them in the OAuth consent screen page?

a)

Test users are random users that will be assigned to test our app in order for it to be verified

b)

Test users need to be added because they are the only Google accounts that will be allowed to log in to our app

c)

Test users are users that will be notified when we release new versions of our app

d)

Test users are accounts that don't have to authorize our app in order to use it, this allows them to skip the consent screen when they log in

20.

How does a user log into Google from our app?

a)

We save the user's gmail address and password to a file and use that to log in

b)

The code opens a browser window and the user completes an authorization flow

c)

The user is asked to type their gmail address and password into the shell when the code is run

d)

The user doesn't have to log in as long as their gmail address was added to our list of test users

21.

Google APIs:

a)

Allow you to use google services and access account data with read only permissions

b)

Allow you to use google services and access account data with full permissions

c)

Allow you to use google services and access data with the permissions requested by the app scopes and authorized by the user

d)

Allow you to use google services but do not allow you to access user account data

22.

What is the librosa library used for?

a)

Analyzing audio

b)

Manipulating audio

c)

Applying effects to audio

d)

Librosa is used for all of these

23.

What does the map() function do?

a)

It creates a 2D visualization of an object

b)

It applies a function to each element in a list or other iterable type

c)

It iterates through a list until it finds the specified item and applies the function to it

d)

It applies a function once collectively to an entire list

24.

When will a pygame sound stop playing?

a)

When the end of the sound file is reached

b)

When the .stop() function is called

c)

When the next sound is played

d)

When the end of the sound file is reached or the .stop() function is called

25.

The map function allows us to:

a)

avoid defining a list

b)

avoid writing a for-loop

c)

define an unnamed function a single line

d)

convert an object to a list of attributes

26.

What are sockets?

a)

Endpoints for sending and receiving data used in internet communication

b)

The numbers which identify your computer to other computers on a network

c)

A number assigned to you by your internet service provider

d)

A place to plug in your laptop charger

27.

What is TCP?

a)

Telecommunications Connection Process

b)

Transfer Cable Port

c)

Transmission Control Protocol

d)

Traffic Consistency Paradox

28.

What happens in TCP that makes it more reliable than simply sending information to a destination?

a)

The sender always sends multiple copies of information at a time to its destination in case one copy is lost

b)

The receiver sends an acknowledgement message to the sender to let them know the information was received

c)

The sender always sends information to the main destination as well as a backup destination in case the receiver is busy

d)

The receiver has to initiate communication, otherwise all incoming messages are blocked

29.

To create a client and server connection on one computer, you must:

a)

Run the client program only, the server is running on the internet

b)

Run the server program in first an online Python environment and run the client in an IDE like Thonny

c)

Run the client program first in the terminal on your computer, then run the server program in an IDE like Thonny

d)

Run the server program first in the terminal on your computer, then run the client program in an IDE like Thonny

30.

What are all the possible parts of a try block in Python?

a)

try, catch

b)

try, catch, finally

c)

try, except

d)

try, except, finally

31.

What does connecting over localhost do?

a)

Allows us to communicate over the Internet

b)

Creates a connection within the same machine

c)

Creates a connection between the computer and our wifi network which acts as the host

d)

Allows us to connect over our local area network

32.

What does the echo client do?

a)

Waits for a connection, receives a message, and sends the message back to the server

b)

Establishes a connection with the server, sends a message, and then confirms that is has received the message back

c)

Waits for a connection, then sends a welcome message to the server

d)

Establishes a connection and receives a welcome message from the server

33.

A message sent over a connection is:

a)

A string containing the message text

b)

A python object called a SocketMessage

c)

An encrypted string containing the message text that must be decoded

d)

A byte array containing the message text that must be decoded

34.

What are threads?

a)

Identical copies of a program file running in different locations

b)

Methods that are inherited from a superclass

c)

Tasks running simultaneously from the same code

d)

Connections between each client and server

35.

Starting a new thread:

a)

Runs the entire python file from the top

b)

Runs a specified method, but cannot take any arguments

c)

Runs a specified method with the arguments provided

d)

Runs only the part of the code within the thread loop

36.

In a client-server connection where a single server can connect to one or more clients at the same time, which part of the code requires us to implement multithreading?

a)

The server code

b)

The client code

c)

Both require multithreading

d)

Neither require multithreading

37.

Which is NOT a necessary step in order to use Google APIs?

a)

Register our app and configure the OAuth consent screen

b)

Create a credentials file and download it

c)

Enable the API we want to use in the Google API library

d)

Defining all scopes in the developer console

38.

What does the echo server do?

a)

Waits for a connection, receives a message, and sends the message back to the client

b)

Establishes a connection with the client, sends a message, and then confirms that is has received the message back

c)

Waits for a connection, then sends a welcome message to the client

d)

Establishes a connection and receives a welcome message from the client

39.

To use sounds in pygame, we must include:

a)

pygame.mixer.init()

b)

pygame.init()

c)

either pygame.mixer.init() or pygame.init()

d)

There is no requirement to use pygame sounds other than importing pygame

40.

How do thread locks work?

a)

Locks prevent any threads from accessing the parent thread variables until a certain point in the program

b)

Locks block specific threads from ever editing the shared variables, so one thread becomes the "writer"

c)

Locks put access to variables on a timer, so a given thread may have access for only a set amount of time before access is passed to the next thread

d)

Locks allow a thread to gain access to a variable and block other threads from accessing it until the variable is unlocked