SlideShare a Scribd company logo
1 of 12
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

Algorithm analysis and design
Algorithm analysis and designAlgorithm analysis and design
Algorithm analysis and designMegha V
 
Solving Simultaneous Linear Equations-1.pptx
Solving Simultaneous Linear Equations-1.pptxSolving Simultaneous Linear Equations-1.pptx
Solving Simultaneous Linear Equations-1.pptxabelmeketa
 
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.pptxabelmeketa
 
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.pptxabelmeketa
 
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 stringsshyaminfo04
 
Chapter 14 Searching and Sorting
Chapter 14 Searching and SortingChapter 14 Searching and Sorting
Chapter 14 Searching and SortingMuhammadBakri13
 
Creating a program from flowchart
Creating a program from flowchartCreating a program from flowchart
Creating a program from flowchartMax 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 algorithmDavid Burks-Courses
 
Algorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching AlgorithmsAlgorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching AlgorithmsMohamed Loey
 
ISMG 2800 123456789
ISMG 2800 123456789ISMG 2800 123456789
ISMG 2800 123456789etirf1
 
Joc live session
Joc live sessionJoc live session
Joc live sessionSIT 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 - AlgorithmMd Sadequl Islam
 

What's hot (19)

Java small steps - 2019
Java   small steps - 2019Java   small steps - 2019
Java small steps - 2019
 
Algorithm analysis and design
Algorithm analysis and designAlgorithm analysis and design
Algorithm analysis and design
 
Solving Simultaneous Linear Equations-1.pptx
Solving Simultaneous Linear Equations-1.pptxSolving Simultaneous Linear Equations-1.pptx
Solving Simultaneous Linear Equations-1.pptx
 
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
 
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
 
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
 
selection structures
selection structuresselection structures
selection structures
 
Chapter 14 Searching and Sorting
Chapter 14 Searching and SortingChapter 14 Searching and Sorting
Chapter 14 Searching and Sorting
 
Functions
FunctionsFunctions
Functions
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Function Pointer in C
Function Pointer in CFunction Pointer in C
Function Pointer in C
 
Creating a program from flowchart
Creating a program from flowchartCreating a program from flowchart
Creating a program from flowchart
 
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
 
Algorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching AlgorithmsAlgorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching Algorithms
 
ISMG 2800 123456789
ISMG 2800 123456789ISMG 2800 123456789
ISMG 2800 123456789
 
Joc live session
Joc live sessionJoc live session
Joc live session
 
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
 
L10 sorting-searching
L10 sorting-searchingL10 sorting-searching
L10 sorting-searching
 

Viewers also liked

Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3JenniferBall44
 
Metal fabrication – canada – february 2017
Metal fabrication – canada – february 2017Metal fabrication – canada – february 2017
Metal fabrication – canada – february 2017paul 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 WorkshopMonica 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 ForecastingIJERA 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 designJenniferBall45
 
Java. Интерфейс Set - наборы (множества) и его реализации.
Java. Интерфейс Set - наборы (множества) и его реализации.Java. Интерфейс Set - наборы (множества) и его реализации.
Java. Интерфейс Set - наборы (множества) и его реализации.Unguryan Vitaliy
 

Viewers also liked (14)

Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3
 
Metal fabrication – canada – february 2017
Metal fabrication – canada – february 2017Metal fabrication – canada – february 2017
Metal fabrication – canada – february 2017
 
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
 
Editing Functionality - Apollo Workshop
Editing Functionality - Apollo WorkshopEditing Functionality - Apollo Workshop
Editing Functionality - Apollo Workshop
 
Slide dengue
Slide dengueSlide dengue
Slide dengue
 
Brochure mbaip 2017
Brochure mbaip 2017 Brochure mbaip 2017
Brochure mbaip 2017
 
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...
 
Compresores de archivos (1)
Compresores de  archivos (1)Compresores de  archivos (1)
Compresores de archivos (1)
 
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...
 
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
 
Problemasfisica2
Problemasfisica2Problemasfisica2
Problemasfisica2
 
Proekt prezentacija (7)
Proekt prezentacija (7)Proekt prezentacija (7)
Proekt prezentacija (7)
 
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
 
Java. Интерфейс Set - наборы (множества) и его реализации.
Java. Интерфейс Set - наборы (множества) и его реализации.Java. Интерфейс Set - наборы (множества) и его реализации.
Java. Интерфейс Set - наборы (множества) и его реализации.
 

Similar to Ecs 10 programming assignment 4 loopapalooza

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 3Mohamed Essam
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingMax Kleiner
 
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.docxdunhamadell
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptxSayanSen36
 
Python programing
Python programingPython programing
Python programinghamzagame
 
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.docxransayo
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.pptjaba 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.docxabhi353063
 
Python-review1.pdf
Python-review1.pdfPython-review1.pdf
Python-review1.pdfpaijitk
 
Understanding F# Workflows
Understanding F# WorkflowsUnderstanding F# Workflows
Understanding F# Workflowsmdlm
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02auswhit
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxpriestmanmable
 

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
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software Testing
 
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
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
Python programing
Python programingPython programing
Python programing
 
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
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
 
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
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
 
Python-review1.pdf
Python-review1.pdfPython-review1.pdf
Python-review1.pdf
 
Understanding F# Workflows
Understanding F# WorkflowsUnderstanding F# Workflows
Understanding F# Workflows
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
 

Recently uploaded

Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 

Recently uploaded (20)

Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 

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