0% found this document useful (0 votes)
194 views

Unit 4

This document contains a 5 question quiz on Python functions and modules. It also provides 3 exercises to create functions: 1) a function that returns the largest of 3 number inputs, 2) a function that returns the longest of 3 string inputs, and 3) a function that compares an input argument to a random variable, printing if the guess is too high, low, or correct.

Uploaded by

api-319267329
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views

Unit 4

This document contains a 5 question quiz on Python functions and modules. It also provides 3 exercises to create functions: 1) a function that returns the largest of 3 number inputs, 2) a function that returns the longest of 3 string inputs, and 3) a function that compares an input argument to a random variable, printing if the guess is too high, low, or correct.

Uploaded by

api-319267329
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Unit 4 Quiz

1. What are modules?


A. They are files containing variables and functions that you
can import
B. They are square roots you can import
C. They are math functions you can import
2. What
A.
B.
C.

is the purpose of a parameter/argument?


They are required when defining/making a function
They act as input the user enters when running a function
They are limitations when making a variable

3. I cannot call another function while defining a function


A. True
B. False
4. All variables are part of a type (string, int, float etc etc).
A. True
B. False
5. A function can have more than one parameter/argument.
A. True
B. False

Unit 4 Exercises
Create a function that accepts three inputs and returns the largest of
the inputs. Dont forget to run the function after defining it and enter
numbers as the inputs! (Dont enter strings!)
Now, create a function that accepts three inputs and returns the
longest of the inputs. Dont forget to run the function after defining it
and enter strings as the inputs! (Hint: In this case, use len() to find the
longest string)
Using the python file as the base, have this function compare the
parameter/argument to a random variable generated in the base code.
If the argument entered is less than the random variable, print (Wrong
guess! The number is bigger.). If the argument entered is greater than
the random variable, print (Wrong guess! The number is smaller.). If
the argument entered is same as the random variable, print (Bingo!
You have guessed correctly!).

You might also like