0% found this document useful (0 votes)
1K views

Cs 1101 Programming Assign Unit 2

This document contains instructions for a programming assignment in a CS1101 course at the University of the People. Students are asked to create a Python script called tryme4.py using the IDLE development environment. The script must include functions for new_line(), three_lines(), nine_lines(), and clear_screen() and call these functions to print specific numbers of lines. Comments are required to explain the code. Students must submit their Python script and output produced when running the script. The grading rubric assesses whether the assignment meets the requirements.

Uploaded by

rah h
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Cs 1101 Programming Assign Unit 2

This document contains instructions for a programming assignment in a CS1101 course at the University of the People. Students are asked to create a Python script called tryme4.py using the IDLE development environment. The script must include functions for new_line(), three_lines(), nine_lines(), and clear_screen() and call these functions to print specific numbers of lines. Comments are required to explain the code. Students must submit their Python script and output produced when running the script. The grading rubric assesses whether the assignment meets the requirements.

Uploaded by

rah h
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

lOMoARcPSD|5493832

CS 1101 Programming Assign. Unit 2

Programming Fundamentals (University of the People)

StuDocu is not sponsored or endorsed by any college or university


Downloaded by sidharth h ([email protected])
lOMoARcPSD|5493832

 Home
 My courses
 CS 1101 - AY2021-T3
 4 February - 10 February
 Programming Assign. Unit 2
 My submission

Programming Assign. Unit 2


My submission
Instructions for submission

Using IDLE
IDLE is a particular Integrated Development Environment (IDE) that is typically included in a Python
installation. An IDE will enable you to use a text editor to create programs (in the case of Python, we
refer to the program as a script) as well as execute the program. The IDLE editor understands the
syntax of the Python programming language and can help you to debug your program by identifying
code that is not valid and must be corrected.
When you first start IDLE, it will display a window that is the Python interpreter. You can type Python
commands directly into this environment, and Python will interpret and execute them.
For all of the assignments in this course, you must create a script. To create a script, select "New
window" from the "File" menu. This will open a new script file. You can also use the "Open" or
"Recent files" options under the "File" menu to open files that you have previously created.
You can enter your script into the window that opens when you use the "New window" option. Before
executing your script, you must save it. The first time you attempt to save a new script, you will need
to give it a name. All Python scripts must have the suffix of .py on the filename.
To execute a script, you can select the "Run Module" option under the "Run" menu, or optionally
press F5 on your keyboard.

Assignment
Using the IDLE development environment, create a Python script named tryme4.py. (Note: an
alternative to IDLE is to use a free account on the pythonanywhere
website: https://www.pythonanywhere.com/)
IDLE has both an interactive mode and a script mode. You must use the script mode to develop
your script. Your script must use meaningful variable names and have comments that describe what
is happening in your script. Comments may describe the assignment of a value to a variable, a
computation and the assignment of the result to a variable, or the display of the result.
Write a function in this file called nine_lines that uses the function three_lines (provided
below) to print a total of nine lines.
Now add a function named clear_screen that uses a combination of the
functions nine_lines, three_lines, and new_line (provided below) to print a total of twenty-

Downloaded by sidharth h ([email protected])


lOMoARcPSD|5493832

five lines. The last line of your program should call first nine_lines and then
the clear_screen function.
The function three_lines and new_line are defined below so that you can see nested function
calls. Also, to make counting “blank” lines visually easier, the print command inside new_line will
print a dot at the beginning of the line:
def new_line():
print('.')
def three_lines():
new_line()
new_line()
new_line()

Submit your Python script file in the posting of your assignment. Your Python script should be either
a .txt file or a .py file.
You must execute your script and paste the output produced into a document that you will submit
along with your Python script.
It is very helpful if you print a placeholder between the printing of 9 lines and the printing of 25 lines.
It will make your output easier to read for your peer assessors. A placeholder can be output such as
“Printing nine lines” or “Calling clearScreen()”.
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?

Programming Assign. Unit 2


submitted on Monday, 8 February 2021, 12:47 AM
- Python script
def new_line(): #prining of one new line function
print('.')

Downloaded by sidharth h ([email protected])


lOMoARcPSD|5493832

def three_lines(): #prining ofthree new lines function


new_line()
new_line()
new_line()

def nine_lines(): #prining of nine new lines function


three_lines()
three_lines()
three_lines()

import os
def clear_screen(): #the screen clear function
if os.name == 'posix':
_ = os.system('clear')
else:
_ = os.system('cls')

#the function used to make the above functions get the 9 lines needed when combining.
print('Printing 9 lines...')
nine_lines()
clear_screen()

#the function used to make the above functions get the 25 lines needed when combining.
print('Printing 25 lines...')
nine_lines()
nine_lines()
three_lines()
three_lines()
new_line()
clear_screen()

- The results are:


================= RESTART: D:/UoPeople/CS_1101/Unit 2/tryme4.py ================

Downloaded by sidharth h ([email protected])


lOMoARcPSD|5493832

Printing 9 lines...
.
.
.
.
.
.
.
.
.
Printing 25 lines...
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

Downloaded by sidharth h ([email protected])


lOMoARcPSD|5493832

.
.
.
>>>

 Programming Assign. Unit 2.docx


 tryme4.py

Assessment
Grade: 90 of 90
Assessment form

Aspect 1
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?

Program implements all 5: 5 points


Program implements 4 of 5: 4 points
Program implements 3 of 5: 3 points
Program implements 2 of 5: 2 points
Program implements 1 of 5: 1 point
Grade for Aspect 1
5/5
Comment for Aspect 1

Aspect 2
Does the assignment demonstrate the use of nested function calls?
Grade for Aspect 2
Yes
Comment for Aspect 2

Aspect 3

Downloaded by sidharth h ([email protected])


lOMoARcPSD|5493832

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.
Grade for Aspect 3
Yes
Comment for Aspect 3

Aspect 4
Does the program code include comments where appropriate?
Grade for Aspect 4
Yes
Comment for Aspect 4

Overall feedback

pls contact me via


[email protected]
love your work and would love to know more about you
you're a good programmer
Assessment
Grade: 90 of 90
Assessment form

Aspect 1
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?

Program implements all 5: 5 points


Program implements 4 of 5: 4 points
Program implements 3 of 5: 3 points
Program implements 2 of 5: 2 points
Program implements 1 of 5: 1 point

Downloaded by sidharth h ([email protected])


lOMoARcPSD|5493832

Grade for Aspect 1


5/5
Comment for Aspect 1

Aspect 2
Does the assignment demonstrate the use of nested function calls?
Grade for Aspect 2
Yes
Comment for Aspect 2

Aspect 3
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.
Grade for Aspect 3
Yes
Comment for Aspect 3

Aspect 4
Does the program code include comments where appropriate?
Grade for Aspect 4
Yes
Comment for Aspect 4

Overall feedback

Downloaded by sidharth h ([email protected])


lOMoARcPSD|5493832

Overall, this is an excellent assignment paper. The student has not only written the codes correctly
and produced the results successfully, but also has written down comments where it is needed.
His/her comments has made the codes more understanble and readable to the reader.

Downloaded by sidharth h ([email protected])

You might also like