Module 2, 2.1.1 Python Functions

¡Supera tus tareas y exámenes ahora con Quizwiz!

Python function

Evaluates a value that may produce a result and/or causes some effect (ie. print).

T/F A Python function requires atleast 1 argument.

False

T/F In Python you cannot write your own functions.

False

T/F Python requires a semicolon ; to be used between multiple instructions on the same line. Example: print('Hello") ; print("What is your name")

False

T/F Python requires that there cannot be an empty line.

False

T/F The code print("My", "name", "is", "Monty", "Python.", sep="-") is invalid and will produce an error.

False

T/F The code print('\\') will produce an error.

False

T/F The print() function evaluates the value of the arguments passed to it.

False

T/F This is a valid function: print ("Hello", end=" ", "Joe")

False

T/F During the execution of a function, Python temporarily leaves your code to execute the function.

True, the function takes the arguments you feed to it.

string

The data type in the argument, print("Hello World").

the positional way

The first argument is outputted before the second argument. The argument's meaning comes from its position in the function.

keyword argument

The meaning of these argument is taken from the special word (keyword) used to identify them.

print("Hello World")

The python function that will output the words Hello World onto the screen.

end keyword

A keyword argument that determines the characters the print() function sends to the output once it reaches the end of its positional arguments.

Argument

A very important component of a function enclosed in parentheses.

A positional argument in the print("Hello","Joe") function.

Hello or Joe

The results of the code print("My", "name", "is", "Monty", "Python.", sep="-").

My-name-is-Monty-Python.

The results of the code: print("My", "name", "is", sep="_", end="*") print("Monty", "Python.", sep="*", end="*\n")

My_name_is*Monty*Python.*

The results of the code print("My", "name", "is", "Monty", "Python.", sep="").

MynameisMontyPython.

T/F A keyword argument must be put after the last positional argument.

True

T/F In Python, functions and other resources are coded in components called modules.

True

T/F Python comes with 69 built-in functions.

True

T/F Python functions require ( ) , a pair of parentheses.

True

T/F Python requires that there cannot be more that one instruction in a line of code.

True

T/F The code print("My", "name", "is", "Monty", "Python.", sep="-") is using the keyword sep.

True

T/F The code print("The itsy bitsy spider" , "climbed up" , "the waterspout.") contains 3 arguments.

True

T/F The code print('\') will produce an error.

True

T/F The code print() will produce a blank line or newline in the output.

True

T/F The print function automatically puts spaces between arguments that are separated by a comma.

True

T/F The print() function has an effect on the arguments passed to it.

True

T/F The print() function is able to operate with virtually all types of data. (strings, numbers, characters, logical values, objects)

True

T/F The string assigned to the end keyword can be any length.

True

T/F This is a valid function: print ("Hello", "Joe", end=" ")

True

A keyword used with the print() function

end

\n

newline character

\ (backslash)

the escape character


Conjuntos de estudio relacionados

B: Matrices and Rational Functions

View Set

QUIZ "The Love Song of J. Alfred Prufrock" by T.S. Eliot

View Set

MedSurg: NCLEX: Liver/Pancreas/Gallbladder

View Set

COMPTIAA+ 220-901 -Hardware and Network Troubleshooting, 4.1;Given a scenario, troubleshoot common problems related to motherboards, RAM, CPU and power with appropriate tools.

View Set

Chapter 1 An Overview of Nutrition

View Set

Chapter 44 Assessment and Management of Patients with Biliary Disorders PrepU

View Set

Chapter 8 LearnSmart ReadingAssignment

View Set

Chapter 4 - Health Insurance Providers

View Set