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

Programming Assign Unit 2

This document defines four Python functions - new_line(), three_lines(), nine_lines(), and clear_screen() - to print an increasing number of new lines. new_line() prints one line, three_lines() uses new_line() to print three lines, nine_lines() uses three_lines() to print nine lines, and clear_screen() combines the previous functions to print twenty-five lines total. The document also includes calls to nine_lines() and clear_screen() to test and demonstrate the functions.

Uploaded by

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

Programming Assign Unit 2

This document defines four Python functions - new_line(), three_lines(), nine_lines(), and clear_screen() - to print an increasing number of new lines. new_line() prints one line, three_lines() uses new_line() to print three lines, nine_lines() uses three_lines() to print nine lines, and clear_screen() combines the previous functions to print twenty-five lines total. The document also includes calls to nine_lines() and clear_screen() to test and demonstrate the functions.

Uploaded by

Safa Hamaizia
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming Assign.

Unit 2
University of the People
CS 1101: PROGRAMMING FUNDAMENTALS
Damian Kravets, Instructor
June 30, 2021

Input :

# First function definition


def new_line(): # Printing one new line
print('.')

# Second function definition


def three_lines(): # Printing three new lines using the first function named new_line three
times
new_line()
new_line()
new_line()

# Third function definition


def nine_lines(): # Printing nine new lines using the second function named three_lines three
times
three_lines()
three_lines()
three_lines()

# Fourth function definition


def clear_screen(): # printing twenty-five new lines with the combination of the three
functions nine_lines, three_lines, and new_line
nine_lines()
nine_lines()
three_lines()
three_lines()
new_line()
# It’s a simple numerical reasoning since 25 = 9 + 9 + 3 + 3 + 1

# Finally, calling the functions we used above to do the program


# Also, printing a placeholder between the printing of 9 lines and the printing of 25 lines

print('Printing nine lines') # This is to get a placeholder in the output


nine_lines()

print('Printing twenty-five lines') # This is also to get the second placeholder in the output
clear_screen()

Output :
#Print 9 "." lines
Printing nine lines
.
.
.
.
.
.
.
.
.

#Print 25 "." lines


Printing twenty-five lines
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
>>>

You might also like