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".
Ad

More Related Content

What's hot (19)

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

Viewers also liked (14)

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

Similar to Ecs 10 programming assignment 4 loopapalooza (20)

Intro to programing with java-lecture 3
Intro to programing with java-lecture 3Intro to programing with java-lecture 3
Intro to programing with java-lecture 3
Mohamed Essam
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
PhanMinhLinhAnxM0190
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
RohitSindhu10
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
AkashdeepBhattacharj1
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software Testing
Max Kleiner
 
made it easy: python quick reference for beginners
made it easy: python quick reference for beginnersmade it easy: python quick reference for beginners
made it easy: python quick reference for beginners
SumanMadan4
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docx
dunhamadell
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
SayanSen36
 
Python programing
Python programingPython programing
Python programing
hamzagame
 
9 11 25 14 44 6 41 15 57 9 39 16 41 2 58 8 43 12 4.docx
9 11 25 14 44 6 41 15 57 9 39 16 41 2 58 8 43 12 4.docx9 11 25 14 44 6 41 15 57 9 39 16 41 2 58 8 43 12 4.docx
9 11 25 14 44 6 41 15 57 9 39 16 41 2 58 8 43 12 4.docx
ransayo
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
Anonymous9etQKwW
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
jaba kumar
 
This first assignment will focus on coding in Python, applying kno.docx
This first assignment will focus on coding in Python, applying kno.docxThis first assignment will focus on coding in Python, applying kno.docx
This first assignment will focus on coding in Python, applying kno.docx
abhi353063
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
snowflakebatch
 
Python-review1.pdf
Python-review1.pdfPython-review1.pdf
Python-review1.pdf
paijitk
 
Python-review1 for begineers to code.ppt
Python-review1 for begineers to code.pptPython-review1 for begineers to code.ppt
Python-review1 for begineers to code.ppt
freyjadexon608
 
Understanding F# Workflows
Understanding F# WorkflowsUnderstanding F# Workflows
Understanding F# Workflows
mdlm
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02
auswhit
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
ibrahim386946
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
RobinRohit2
 
Intro to programing with java-lecture 3
Intro to programing with java-lecture 3Intro to programing with java-lecture 3
Intro to programing with java-lecture 3
Mohamed Essam
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software Testing
Max Kleiner
 
made it easy: python quick reference for beginners
made it easy: python quick reference for beginnersmade it easy: python quick reference for beginners
made it easy: python quick reference for beginners
SumanMadan4
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docx
dunhamadell
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
SayanSen36
 
Python programing
Python programingPython programing
Python programing
hamzagame
 
9 11 25 14 44 6 41 15 57 9 39 16 41 2 58 8 43 12 4.docx
9 11 25 14 44 6 41 15 57 9 39 16 41 2 58 8 43 12 4.docx9 11 25 14 44 6 41 15 57 9 39 16 41 2 58 8 43 12 4.docx
9 11 25 14 44 6 41 15 57 9 39 16 41 2 58 8 43 12 4.docx
ransayo
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
jaba kumar
 
This first assignment will focus on coding in Python, applying kno.docx
This first assignment will focus on coding in Python, applying kno.docxThis first assignment will focus on coding in Python, applying kno.docx
This first assignment will focus on coding in Python, applying kno.docx
abhi353063
 
Python-review1.pdf
Python-review1.pdfPython-review1.pdf
Python-review1.pdf
paijitk
 
Python-review1 for begineers to code.ppt
Python-review1 for begineers to code.pptPython-review1 for begineers to code.ppt
Python-review1 for begineers to code.ppt
freyjadexon608
 
Understanding F# Workflows
Understanding F# WorkflowsUnderstanding F# Workflows
Understanding F# Workflows
mdlm
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02
auswhit
 
Ad

Recently uploaded (20)

Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 

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".