def new_line(): print('.') def three_lines(): new_line() new_line() new_line() def nine_lines(): three_lines() three_lines() three_lines() def clearScreen(): print('Printing nine lines') nine_lines() print('Printing nine lines') nine_lines() print('Printing three lines') three_lines() print('Printing three lines') three_lines() print('Printing new line') new_line() print('Line from main function') print('Calling clearScreen function') clearScreen() Assessment The following items will be used in the grading rubric for this assignment. Make sure that you have addressed each item in your assignment. Does the assignment implement new_line, three_lines, nine_lines, and clear_screen functions, as well as a main section of the program which calls the functions? Does the assignment demonstrate the use of nested function calls? Does the assignment produce the appropriate output when executed? The output should be recorded in a text file, a Microsoft Word document, or an RTF-formatted document by copying the output from the Python script into the document. The successful script will print out 9 "." lines first and then 25 "." lines. Does the program code include comments where appropriate?
def new_line():
print('.')
def three_lines():
new_line()
new_line()
new_line()
def nine_lines():
three_lines()
three_lines()
three_lines()
def clearScreen():
print('Printing nine lines')
nine_lines()
print('Printing nine lines')
nine_lines()
print('Printing three lines')
three_lines()
print('Printing three lines')
three_lines()
print('Printing new line')
new_line()
print('Line from main function')
print('Calling clearScreen function')
clearScreen()
Assessment
The following items will be used in the grading rubric for this assignment. Make sure that you have addressed each item in your assignment.
- Does the assignment implement new_line, three_lines, nine_lines, and clear_screen functions, as well as a main section of the
program which calls the functions? - Does the assignment demonstrate the use of nested function calls?
- Does the assignment produce the appropriate output when executed? The output should be recorded in a text file, a Microsoft Word document, or an RTF-formatted document by copying the output from the Python script into the document. The successful script will print out 9 "." lines first and then 25 "." lines.
- Does the program code include comments where appropriate?
Introduction
A function is a block of code that can accept inputs, perform operations on those inputs, and then return one or more values. Functions are a great way to structure and organize your code. In Python, functions are defined using the def
keyword, followed by the name of the function, parentheses containing any parameters to be passed to the function, and a colon. The code block inside the function is then indented.
Step by step
Solved in 4 steps with 2 images