wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CodeHS Computer Science Principles

Total questions: 26

Worksheet time: 52mins

Name
Class
Date
1.

________ allow us to break our programs into smaller parts

a)

decisions

b)

functions

c)

methods

d)

loops

2.

Which is the correct header of a function names double_number that takes one parameter

a)

def double number (x)

b)

def double_number(x)

c)

def double_number(x):

d)

def double_number(int x):

3.

Everything in a function is indented by _____

a)

One Level

b)

Two Levels

c)

Three Levels

d)

In Curly Brackets ({})

4.

To call a previous written function, you use the

a)

function return type

b)

function name without the ()

c)

function name with () and included parameters

d)

function name with ()

5.

The tasks included in a function definition are referred to as the function _______.

a)

method

b)

body

c)

statements

d)

parameters

6.

The variables written inside the () of a functions definition are the _____

a)

return types

b)

arguements

c)

variables

d)

parameters

7.

When functions have multiple parameters, the variables are separated with

a)

commas

b)

colons

c)

simi-colons

d)

periods

8.

True or false. Parameters can have default values?

a)

True

b)

False

9.

Parameters with default values have to come at the _____ of the parameters in the function

a)

beginning

b)

middle

c)

end

10.

Incorrectly writing a default parameter in a function definition will result in ....

a)

a logic error where the program still runs, but incorrectly.

b)

a syntax error, non-default argument follows default argument

c)

a syntax error, incorrect function declaration

d)

a syntax error, incorrect variable declaration in function

11.

When a value from a function is passed back to the function call, it is referred to as a _____

a)

return value

b)

send back value

c)

argument

d)

parameter

12.

They keyword used to tell a function to send the variable value back to where it was called

a)

send

b)

go

c)

return

d)

parameter

13.

True or False. Functions can not call other functions.

a)

True

b)

False

14.

Which python statement allows you to save the return value from a function inside a variable?

a)

return element

b)

print(function_name())

c)

variable = function_name()

d)

function_name()

15.

Which python statement allows you to print the return value from a function

a)

return element

b)

print(function_name())

c)

variable = function_name()

d)

function_name()

16.

Which is correct?

a)

Functions take in parameters and give back results called return values

b)

Parameters take in functions and give back results called return values

c)

Return types take in functions and give back results called parameters

d)

Functions take in return values and give back results called parameters

17.

A _____ is the collection of variable names that exist at a certain point in your code

a)

Scope

b)

Local Scope

c)

Global Scope

d)

Namespace

18.

____ refers to where the variable exists within a program.

a)

Scope

b)

Local scope

c)

Global scope

d)

Namespace

19.

When a variable is defined in a function it is in

a)

The functions local scope

b)

The global scope of the program

c)

Everywhere below that line

d)

In the entire namespace

20.

Every programming language has a ______

a)

API

b)

Karel API

c)

Standard Library

d)

Functions

21.

A _____ is a set of tools for building programs

a)

Application Programming Interface

b)

A-frame Pixel Interface

c)

Assistant Program Information

d)

Abstract Programming Interface

22.

True or False. Karel is an example of an API.

a)

True

b)

False

23.

A good API __________ complex details involved in getting the program to work

a)

hides

b)

gets rid of

c)

abstracts away

d)

deletes

24.

________ provides information to show programmers how to use an API

a)

Comments

b)

The orginal code

c)

Documentation

d)

Commands

25.

Companies like Twitter, Facebook and Spotify provide an API for other programs to ______

a)

use their applications

b)

interact with their site and their data

c)

make it hard to connect the applications

d)

see how the site was created

26.

Which is an example of an API we see today

a)

Tweeting from the twitter webpage

b)

Posting a status update on Facebook

c)

Uploading a photo to Instagram

d)

Adding a Spotify music player on your own webpage