SlideShare a Scribd company logo
ECS 10Programming Assignment 4 - Loopapalooza
To Purchase This Material Click below Link
http://www.tutorialoutlet.com/all-miscellaneous/ecs-
10-programming-assignment-4-loopapalooza/
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Programming Assignment 4 - Loopapalooza
ECS 10 - Winter 2017
All solutions are to be written using Python 3. Make sure you provide
comments
including the file name, your name, and the date at the top of the file
you submit.
Also make sure to include appropriate docstrings for all functions.
The names of your functions must exactly match the names given in
this assignment.
The order of the parameters in your parameter list must exactly match
the order
given in this assignment. All loops in your functions must be while
loops. If you've
been reading ahead, you may have discovered lists and conclude that
a list may be
the key to solving one or more of the problems below. That would be
an incorrect
conclusion; don't use lists in this programming assignment. While
we're talking
about things you should not use, do not use the Python functions sum,
min, or max.
Please note that in all problems, the goal is to give you practice using
loops, not
finding ways to avoid them. Every solution you write for this
assignment must
make appropriate use of a while loop.
For any given problem below, you may want to write additional
functions other
than those specified for your solution. That's fine with us.
One other thing: if you haven't already done so, or even if you have,
go to our
Course Information page on SmartSite and read the section on
Academic
Misconduct. Submitting other people's work as your own, including
solutions you
may find on the Internet, is not permitted and will be referred to
Student Judicial
Affairs. Problem 1
Create a Python function called sumOfOdds which takes one
argument, an integer greater than
or equal to 1, and returns the result of adding the odd integers
between 1 and the value of the
given argument (inclusive). This function does not print. You may
assume that the argument is
valid. Here are some examples of how your function should behave:
>>> sumOfOdds(1)
1
>>> sumOfOdds(2)
1
>>> sumOfOdds(3)
4
>>> sumOfOdds(4)
4
>>> sumOfOdds(5)
9
>>> sumOfOdds(100)
2500
>>> sumOfOdds(101)
2601
>>> Problem 2
Create a Python function called productOfPowersOf2 which takes
two arguments, both of
which are non-negative integers. For purposes of this problem, let's
call the first argument exp1
and the second argument exp2. Your function should compute and
return (not print) the
product of all powers of 2 from 2exp1 to 2exp2. Here are some
examples of how your function
should behave:
>>> productOfPowersOf2(0,0)
1
>>> productOfPowersOf2(1,1)
2
>>> productOfPowersOf2(1,2)
8
>>> productOfPowersOf2(1,3)
64
>>> productOfPowersOf2(1,4)
1024
>>> productOfPowersOf2(1,5)
32768
>>> productOfPowersOf2(2,4)
512
>>> productOfPowersOf2(3,12)
37778931862957161709568
>>> Problem 3
Create a Python function called printAsterisks that expects one
argument, a nonnegative integer, and prints a row of asterisks, where
the number of asterisks is given by
the value passed as the argument. Control the printing with a while
loop, not with a
construct that looks like print("*" * n). This function does
not return any value.
Here are some examples of how your function should behave:
>>> printAsterisks(1)
*
>>> printAsterisks(2)
**
>>> printAsterisks(3)
***
>>> printAsterisks(4)
****
>>> printAsterisks(0)
>>> Problem 4
Create a Python function called printTrianglthat expects one
argument, a nonnegative integer, and prints a right triangle, where
both the height of the triangle and the
width of the base of the triangle are given by the value passed as the
argument. This
function does not return any value. Your function should use your
solution to Problem 3
in printing the triangle. Here are some examples of how your function
should behave:
>>> printTriangle(4)
*
**
***
****
>>> printTriangle(3)
*
**
***
>>> printTriangle(2)
*
**
>>> printTriangle(1)
*
>>> printTriangle(0)
>>> Problem 5
Create a function called allButMax that expects no arguments.
Instead, this function
gets its input from the user at the keyboard. The function asks the user
to enter a series of
numbers greater than or equal to zero, one at a time. The user types
end to indicate that
there are no more numbers. The function computes the sum of all the
values entered
except for the maximum value in the series. (Think of this as dropping
the highest
homework score from a series of homework scores.) The function
then both prints the
sum and returns the sum. You may assume the user inputs are valid:
they will either be a
number greater than or equal to zero, or the string end. Here are some
examples of how
your function should behave:
>>> allButMax()
Enter next number: 20
Enter next number: 30
Enter next number: 40
Enter next number: end
The sum of all values except
50.0
>>> allButMax()
Enter next number: 1.55
Enter next number: 90
Enter next number: 8.45
Enter next number: 2
Enter next number: end
The sum of all values except
12.0
>>> x = allButMax()
Enter next number: 3
Enter next number: 2
Enter next number: 1
Enter next number: end
The sum of all values except
>>> print(x)
3.0
>>> allButMax()
Enter next number: end
The sum of all values except
0 for the maximum value is: 50.0 for the maximum value is: 12.0 for
the maximum value is: 3.0 for the maximum value is: 0 Problem 6
Create a function called avgSumOfSquares that expects no arguments.
Instead, this
function gets its input from the user at the keyboard. The function
asks the user to enter a
series of numbers, one at a time. The user types end to indicate that
there are no more
numbers. The function computes the average of the sum of the
squares of all the values
entered. For example, given the values 6, -3, 4, 2, 11, 1, and -9, the
sum of the squares
would be (36 + 9 + 16 + 4 + 121 + 1 + 81) = 268. The average of the
sum of squares
would then be 268/7 = 38.285714285714285.The function then prints
the average of the
sum of the squares and returns that average. However, if end is
entered before any
values are entered, the function notifies the user that no numbers were
entered and returns
None. You may assume the user inputs are valid: they will either be a
number or the
string end. Here are some examples of how your function should
behave:
>>> avgSumOfSquares()
Enter next number: 6
Enter next number: -3
Enter next number: 4
Enter next number: 2
Enter next number: 11
Enter next number: 1
Enter next number: -9
Enter next number: end
The average of the sum of the squares is: 38.285714285714285
38.285714285714285
>>> avgSumOfSquares()
Enter next number: 3.27
Enter next number: -1.9
Enter next number: 6
Enter next number: -1
Enter next number: end
The average of the sum of the squares is: 12.825725
12.825725
>>> avgSumOfSquares()
Enter next number: end
No numbers were entered.
>>> x = avgSumOfSquares()
Enter next number: end
No numbers were entered.
>>> print(x)
None
>>> x = avgSumOfSquares()
Enter next number: -1
Enter next number: 2
Enter next number: -3
Enter next number: end
The average of the sum of the squares is: 4.666666666666667
>>> print(x)
4.666666666666667 Where to do the assignment
You can do this assignment on your own computer, or in the labs. In
either case, use the
IDLE development environment -- that's what we'll use when we
grade your program.
Put all the functions you created in a file called
"prog4.py".
Submitting the Assignment
We will be using SmartSite to turn in assignments. Go to SmartSite,
go to ECS 010, and
go to Assignments. Submit the file containing your functions as an
attachment.
Do NOT cut-and-paste your functions into a text window. Do NOT
hand in a screenshot
of your functions' output. We want one file from you:
"prog4.py".
Saving your work
If you are working in the lab, you will need to copy your program to
your own flash-drive
or save the program to your workspace on SmartSite. To save it on
flash-drive, plug the
flash-drive into the computer (your TAs or the staff in the labs can
help you figure out
how), open the flash-drive, and copy your work to it by moving the
folder with your files
from the Desktop onto the flash-drive. To copy the file to your
SmartSite workspace, go
to Workspace, select Resources, and then use the Add button next to
"MyWorkspace".

More Related Content

What's hot (19)

PDF
Java small steps - 2019
Christopher Akinlade
 
PPTX
Algorithm analysis and design
Megha V
 
PPTX
Solving Simultaneous Linear Equations-1.pptx
abelmeketa
 
PPTX
curve fitting or regression analysis-1.pptx
abelmeketa
 
PPTX
Solving of Non-Linear Equations-1.pptx
abelmeketa
 
DOC
Devry cis 170 c i lab 5 of 7 arrays and strings
shyaminfo04
 
PDF
selection structures
Micheal Ogundero
 
PDF
Chapter 14 Searching and Sorting
MuhammadBakri13
 
PPTX
Functions
PralhadKhanal1
 
DOC
Insertion sort
Dorina Isaj
 
PDF
Sorting Algorithms
Mohammed Hussein
 
PPTX
Function Pointer in C
Lakshmi Sarvani Videla
 
PPT
Creating a program from flowchart
Max Friel
 
PPTX
Sorting and searching arrays binary search algorithm
David Burks-Courses
 
PDF
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
DOCX
ISMG 2800 123456789
etirf1
 
PDF
Joc live session
SIT Tumkur
 
PPTX
Coin Changing, Binary Search , Linear Search - Algorithm
Md Sadequl Islam
 
PPT
L10 sorting-searching
mondalakash2012
 
Java small steps - 2019
Christopher Akinlade
 
Algorithm analysis and design
Megha V
 
Solving Simultaneous Linear Equations-1.pptx
abelmeketa
 
curve fitting or regression analysis-1.pptx
abelmeketa
 
Solving of Non-Linear Equations-1.pptx
abelmeketa
 
Devry cis 170 c i lab 5 of 7 arrays and strings
shyaminfo04
 
selection structures
Micheal Ogundero
 
Chapter 14 Searching and Sorting
MuhammadBakri13
 
Functions
PralhadKhanal1
 
Insertion sort
Dorina Isaj
 
Sorting Algorithms
Mohammed Hussein
 
Function Pointer in C
Lakshmi Sarvani Videla
 
Creating a program from flowchart
Max Friel
 
Sorting and searching arrays binary search algorithm
David Burks-Courses
 
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
ISMG 2800 123456789
etirf1
 
Joc live session
SIT Tumkur
 
Coin Changing, Binary Search , Linear Search - Algorithm
Md Sadequl Islam
 
L10 sorting-searching
mondalakash2012
 

Viewers also liked (14)

DOCX
Ecs40 winter 2017 homework 3
JenniferBall44
 
PPTX
Metal fabrication – canada – february 2017
paul young cpa, cga
 
PPTX
Los reinos cristianos medievales en la península ibérica
Àngels Rotger
 
PDF
Editing Functionality - Apollo Workshop
Monica Munoz-Torres
 
PPTX
Slide dengue
Neuma_neves
 
PDF
Brochure mbaip 2017
AIM Analysis Institute of Management
 
PDF
Locating Facts Devices in Optimized manner in Power System by Means of Sensit...
IJERA Editor
 
PDF
Compresores de archivos (1)
Alex Lopez
 
PDF
A study of Heavy Metal Pollution in Groundwater of Malwa Region of Punjab, In...
IJERA Editor
 
PDF
A Singular Spectrum Analysis Technique to Electricity Consumption Forecasting
IJERA Editor
 
PDF
Problemasfisica2
alejandro amado
 
PPT
Proekt prezentacija (7)
seredukhina
 
DOCX
Entd 313 you will be required to write an 3 5 page technical design
JenniferBall45
 
PPT
Java. Интерфейс Set - наборы (множества) и его реализации.
Unguryan Vitaliy
 
Ecs40 winter 2017 homework 3
JenniferBall44
 
Metal fabrication – canada – february 2017
paul young cpa, cga
 
Los reinos cristianos medievales en la península ibérica
Àngels Rotger
 
Editing Functionality - Apollo Workshop
Monica Munoz-Torres
 
Slide dengue
Neuma_neves
 
Locating Facts Devices in Optimized manner in Power System by Means of Sensit...
IJERA Editor
 
Compresores de archivos (1)
Alex Lopez
 
A study of Heavy Metal Pollution in Groundwater of Malwa Region of Punjab, In...
IJERA Editor
 
A Singular Spectrum Analysis Technique to Electricity Consumption Forecasting
IJERA Editor
 
Problemasfisica2
alejandro amado
 
Proekt prezentacija (7)
seredukhina
 
Entd 313 you will be required to write an 3 5 page technical design
JenniferBall45
 
Java. Интерфейс Set - наборы (множества) и его реализации.
Unguryan Vitaliy
 
Ad

Similar to Ecs 10 programming assignment 4 loopapalooza (20)

PDF
(2 - 1) CSE1021 - Module 2 Worksheet.pdf
ayushagar5185
 
PDF
Sasin nisar
SasinNisar
 
PDF
Python Programming
Sreedhar Chowdam
 
DOCX
NPTEL QUIZ.docx
GEETHAR59
 
PDF
Notes7
Amba Research
 
PPTX
Chapter 02 functions -class xii
Praveen M Jigajinni
 
PDF
pyton Notes9
Amba Research
 
DOCX
1 ECE 175 Computer Programming for Engineering Applica.docx
oswald1horne84988
 
PDF
Python Lab Manual
Bobby Murugesan
 
PPTX
Practice_Exercises_Control_Flow.pptx
Rahul Borate
 
PDF
Python for High School Programmers
Siva Arunachalam
 
PDF
III MCS python lab (1).pdf
srxerox
 
PPTX
Programming Fundamentals in Python - Sequence Structure
Georgios Papadopoulos
 
PPTX
Introduction to Python Programming.pptx
Python Homework Help
 
DOCX
Python Laboratory Programming Manual.docx
ShylajaS14
 
PDF
Practical File waale code.pdf
FriendsStationary
 
DOCX
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 
PDF
xii cs practicals class 12 computer science.pdf
gmaiihghtg
 
PDF
pyton Exam1 soln
Amba Research
 
DOC
Programada chapter 4
abdallaisse
 
(2 - 1) CSE1021 - Module 2 Worksheet.pdf
ayushagar5185
 
Sasin nisar
SasinNisar
 
Python Programming
Sreedhar Chowdam
 
NPTEL QUIZ.docx
GEETHAR59
 
Chapter 02 functions -class xii
Praveen M Jigajinni
 
pyton Notes9
Amba Research
 
1 ECE 175 Computer Programming for Engineering Applica.docx
oswald1horne84988
 
Python Lab Manual
Bobby Murugesan
 
Practice_Exercises_Control_Flow.pptx
Rahul Borate
 
Python for High School Programmers
Siva Arunachalam
 
III MCS python lab (1).pdf
srxerox
 
Programming Fundamentals in Python - Sequence Structure
Georgios Papadopoulos
 
Introduction to Python Programming.pptx
Python Homework Help
 
Python Laboratory Programming Manual.docx
ShylajaS14
 
Practical File waale code.pdf
FriendsStationary
 
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 
xii cs practicals class 12 computer science.pdf
gmaiihghtg
 
pyton Exam1 soln
Amba Research
 
Programada chapter 4
abdallaisse
 
Ad

Recently uploaded (20)

PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 

Ecs 10 programming assignment 4 loopapalooza

  • 1. ECS 10Programming Assignment 4 - Loopapalooza To Purchase This Material Click below Link http://www.tutorialoutlet.com/all-miscellaneous/ecs- 10-programming-assignment-4-loopapalooza/ FOR MORE CLASSES VISIT www.tutorialoutlet.com Programming Assignment 4 - Loopapalooza ECS 10 - Winter 2017 All solutions are to be written using Python 3. Make sure you provide comments including the file name, your name, and the date at the top of the file you submit. Also make sure to include appropriate docstrings for all functions. The names of your functions must exactly match the names given in this assignment. The order of the parameters in your parameter list must exactly match the order given in this assignment. All loops in your functions must be while loops. If you've been reading ahead, you may have discovered lists and conclude that a list may be the key to solving one or more of the problems below. That would be an incorrect
  • 2. conclusion; don't use lists in this programming assignment. While we're talking about things you should not use, do not use the Python functions sum, min, or max. Please note that in all problems, the goal is to give you practice using loops, not finding ways to avoid them. Every solution you write for this assignment must make appropriate use of a while loop. For any given problem below, you may want to write additional functions other than those specified for your solution. That's fine with us. One other thing: if you haven't already done so, or even if you have, go to our Course Information page on SmartSite and read the section on Academic Misconduct. Submitting other people's work as your own, including solutions you may find on the Internet, is not permitted and will be referred to Student Judicial Affairs. Problem 1 Create a Python function called sumOfOdds which takes one argument, an integer greater than or equal to 1, and returns the result of adding the odd integers between 1 and the value of the given argument (inclusive). This function does not print. You may assume that the argument is
  • 3. valid. Here are some examples of how your function should behave: >>> sumOfOdds(1) 1 >>> sumOfOdds(2) 1 >>> sumOfOdds(3) 4 >>> sumOfOdds(4) 4 >>> sumOfOdds(5) 9 >>> sumOfOdds(100) 2500 >>> sumOfOdds(101) 2601 >>> Problem 2 Create a Python function called productOfPowersOf2 which takes two arguments, both of which are non-negative integers. For purposes of this problem, let's call the first argument exp1 and the second argument exp2. Your function should compute and return (not print) the
  • 4. product of all powers of 2 from 2exp1 to 2exp2. Here are some examples of how your function should behave: >>> productOfPowersOf2(0,0) 1 >>> productOfPowersOf2(1,1) 2 >>> productOfPowersOf2(1,2) 8 >>> productOfPowersOf2(1,3) 64 >>> productOfPowersOf2(1,4) 1024 >>> productOfPowersOf2(1,5) 32768 >>> productOfPowersOf2(2,4) 512 >>> productOfPowersOf2(3,12) 37778931862957161709568 >>> Problem 3 Create a Python function called printAsterisks that expects one argument, a nonnegative integer, and prints a row of asterisks, where the number of asterisks is given by
  • 5. the value passed as the argument. Control the printing with a while loop, not with a construct that looks like print("*" * n). This function does not return any value. Here are some examples of how your function should behave: >>> printAsterisks(1) * >>> printAsterisks(2) ** >>> printAsterisks(3) *** >>> printAsterisks(4) **** >>> printAsterisks(0) >>> Problem 4 Create a Python function called printTrianglthat expects one argument, a nonnegative integer, and prints a right triangle, where both the height of the triangle and the width of the base of the triangle are given by the value passed as the argument. This function does not return any value. Your function should use your solution to Problem 3 in printing the triangle. Here are some examples of how your function should behave:
  • 6. >>> printTriangle(4) * ** *** **** >>> printTriangle(3) * ** *** >>> printTriangle(2) * ** >>> printTriangle(1) * >>> printTriangle(0) >>> Problem 5 Create a function called allButMax that expects no arguments. Instead, this function gets its input from the user at the keyboard. The function asks the user to enter a series of numbers greater than or equal to zero, one at a time. The user types end to indicate that
  • 7. there are no more numbers. The function computes the sum of all the values entered except for the maximum value in the series. (Think of this as dropping the highest homework score from a series of homework scores.) The function then both prints the sum and returns the sum. You may assume the user inputs are valid: they will either be a number greater than or equal to zero, or the string end. Here are some examples of how your function should behave: >>> allButMax() Enter next number: 20 Enter next number: 30 Enter next number: 40 Enter next number: end The sum of all values except 50.0 >>> allButMax() Enter next number: 1.55 Enter next number: 90 Enter next number: 8.45 Enter next number: 2 Enter next number: end
  • 8. The sum of all values except 12.0 >>> x = allButMax() Enter next number: 3 Enter next number: 2 Enter next number: 1 Enter next number: end The sum of all values except >>> print(x) 3.0 >>> allButMax() Enter next number: end The sum of all values except 0 for the maximum value is: 50.0 for the maximum value is: 12.0 for the maximum value is: 3.0 for the maximum value is: 0 Problem 6 Create a function called avgSumOfSquares that expects no arguments. Instead, this function gets its input from the user at the keyboard. The function asks the user to enter a series of numbers, one at a time. The user types end to indicate that there are no more numbers. The function computes the average of the sum of the squares of all the values
  • 9. entered. For example, given the values 6, -3, 4, 2, 11, 1, and -9, the sum of the squares would be (36 + 9 + 16 + 4 + 121 + 1 + 81) = 268. The average of the sum of squares would then be 268/7 = 38.285714285714285.The function then prints the average of the sum of the squares and returns that average. However, if end is entered before any values are entered, the function notifies the user that no numbers were entered and returns None. You may assume the user inputs are valid: they will either be a number or the string end. Here are some examples of how your function should behave: >>> avgSumOfSquares() Enter next number: 6 Enter next number: -3 Enter next number: 4 Enter next number: 2 Enter next number: 11 Enter next number: 1 Enter next number: -9 Enter next number: end The average of the sum of the squares is: 38.285714285714285
  • 10. 38.285714285714285 >>> avgSumOfSquares() Enter next number: 3.27 Enter next number: -1.9 Enter next number: 6 Enter next number: -1 Enter next number: end The average of the sum of the squares is: 12.825725 12.825725 >>> avgSumOfSquares() Enter next number: end No numbers were entered. >>> x = avgSumOfSquares() Enter next number: end No numbers were entered. >>> print(x) None >>> x = avgSumOfSquares() Enter next number: -1 Enter next number: 2 Enter next number: -3
  • 11. Enter next number: end The average of the sum of the squares is: 4.666666666666667 >>> print(x) 4.666666666666667 Where to do the assignment You can do this assignment on your own computer, or in the labs. In either case, use the IDLE development environment -- that's what we'll use when we grade your program. Put all the functions you created in a file called "prog4.py". Submitting the Assignment We will be using SmartSite to turn in assignments. Go to SmartSite, go to ECS 010, and go to Assignments. Submit the file containing your functions as an attachment. Do NOT cut-and-paste your functions into a text window. Do NOT hand in a screenshot of your functions' output. We want one file from you: "prog4.py". Saving your work If you are working in the lab, you will need to copy your program to your own flash-drive or save the program to your workspace on SmartSite. To save it on flash-drive, plug the flash-drive into the computer (your TAs or the staff in the labs can help you figure out
  • 12. how), open the flash-drive, and copy your work to it by moving the folder with your files from the Desktop onto the flash-drive. To copy the file to your SmartSite workspace, go to Workspace, select Resources, and then use the Add button next to "MyWorkspace".