Search Header Logo
FUNCTIONS redux

FUNCTIONS redux

Assessment

Presentation

Computers

9th - 12th Grade

Practice Problem

Easy

Created by

Brandon Lopez

Used 4+ times

FREE Resource

0 Slides • 7 Questions

1

Open Ended

Display the following output:

Hello John

Good morning Kevin

Hola Juan

Using only calls to the function below,

def greet(name_to_greet, greeting):

print(greeting, name_to_greet)

2

Open Ended

Convert 2 celsius to Kelvin. Then Convert 32 Fahrenheit to celsius. Your code may only include calls to the functions below.

def convert(f):

c = (f - 32) * (5/9)

print(f, "f =", c, "c")

def convert2(c):

k = c + 273.15

print(c, "c =", k, "k")

3

Open Ended

Get the following output:

Kevin, Jane, Alex

Kevin, Jane, Alex

Your code may only use a function call to the function defined below:

def names(w, x, y, z):

new = (z + ", " + w + ", " + x) + "\n"

new = new * y

print(new)

4

Open Ended

Question image

Get the output shown in the picture, using only a single function call to the function defined below:

def display(a, b, c, d, e):

print("*" * e)

print("*" * c)

print("*" * b)

print("*" * a)

print("*" * d)

5

Open Ended

Question image

Get the output shown in the screenshot using only a single function call to the function defined below:

def display(a, b, c):

bottom = "*" * c

middle = (" " a) + ("*" * b)

top = (" " * (b-1)) + ( "*" )

print(top)

print(middle)

print(bottom)

6

Open Ended

Write a function definition. This function should take two parameters. One parameter for the person's first initial, one for the person's last name. This function should print out the person's name in the following format, for example, if the name is John Doe:

J. Doe

Call the function with 4 names

7

Open Ended

Question image

Write a function definition. This function should take two parameters, side_a, side_b. Using these two parameters, calculate the hypotenuse. Then call the function with the arguments: 4, 3. You should get 5. Then call the function again with arguments: 7, 24. You should get 25.

Display the following output:

Hello John

Good morning Kevin

Hola Juan

Using only calls to the function below,

def greet(name_to_greet, greeting):

print(greeting, name_to_greet)

Show answer

Auto Play

Slide 1 / 7

OPEN ENDED