Hire Experts For Answers
Order NowRelated Study Services
- Homework Answers
- Coursework writing help
- Term paper writing help
- Writing Help
- Paper Writing Help
- Research paper help
- Thesis Help
- Dissertation Help
- Case study writing service
- Capstone Project Writing Help
- Lab report Writing
- Take my online class
- Take my online exam
- Do my test for me
- Do my homework
- Do my math homework
- Online Assignment Help
- Do my assignment
- Essay Writing Help
- Write my college essay
- Write my essay for me
DESCRIPTION
Posted
Modified
Viewed
14
This lab required 4 activities of coding. I need them all done and I need to be bale to save them to a file on my computer. Ive attached a file with the instructions to the lab
This order does not have tags, yet.
Attachments
CS100 Lab 5 – Practice Lab 1
In this lab you will write several programs to practice your basic Python skills. The first three activities
are simple programming exercises, the programs in the last two activities do some image manipulation.
Remember to never start with a blank screen. Copy a program you wrote for a previous lab and modify
it.
Activity 1: Random Test (2 points)
I said that Python’s randint() function returns a random value inside a given range. For example,
randint(1,100) will return a random value between 1 and 100. Let’s test the assertion that
randint() returns a random number by writing a program that calls randint() a number of times
and calculates the average value returned. If randint() is random, you would expect the average to
be close to the middle of the range. In the example above, I would expect the average value to be close
to 50.
Write a program that calls randint(1,100) 10,000 times and returns the average. Once you have
the program written, experiment a little bit. Try different ranges and change the number of times that
you call randint().
Name the file that contains your program lab5-act1.py.
Activity 2: Dice (3 points)
In this activity let’s write a program that uses randint() to simulate tossing a 6 sided die. The
number returned by randint() is not only random, but in addition to being random it is also uniform,
which means any value is equally as likely to be returned (to put this in another way the dice are not
loaded).
Start with the program you wrote in activity one, and change it so the range for randint() is one to
six. Now run the program so that randint() is called 10,000 times, simulating tossing a die 10,000
times. The output from your program should be around three. Now modify the program so that in
addition to calculating the average, it counts the number of times a one is rolled, a two is rolled, a three
is rolled, and so on. When the program is finished “rolling” the die, print out the average and the
number of times each number was rolled. If randint() is uniform each number should have been
rolled about the same number of times.
Here is an important thing to keep in mind about randint(). Remember that every time you call
randint() it will return a random number. So you only want to roll the die once each time through
the loop, so randint() should only be called once each time through the loop. When you call
randint() in your loop, you should save the value that is returned so that you can refer to it as many
times as you need to in the loop. Think variable ����
Name the file that contains your program lab5-act2.py.
Activity 3: Fibonacci Numbers (10 points)
You have probably seen the Fibonacci sequence before. Here are the first few terms in the sequence:
1, 1, 2, 3, 5, 8, 13, 21, 34, …
The first two terms in the sequence are 1 and then 1. After that, each term is the sum of the preceding
two terms. In the example above, the next term in the sequence would be 55 (which is 21+34).
More formally,
F0 = 1
F1 = 1
FN = FN-2 + FN-1
In this activity you will write a Python program that prints out the first 20 terms in the Fibonacci
sequence. The main part of this program will consist of a loop that prints out the sum of the preceding
two terms in the sequence:
for i in range(????):
sum = sum of the last two terms
print(sum)
Somehow you will need to remember what the last two terms were. I sure hope you are thinking, not
variable again ���� Hint: look at the formal definition.
The only other thing you will need to do is to get things started, remember the first two terms in the
sequence are one. You will also have to figure out what range to use to get the first 20 terms. One last
hint: do not try to print everything inside the loop.
Name the file that contains your program lab5-act3.py.
Activity 2: Brighten a Photo (15 points)
You can blame this activity on my decision to binge watch NCIS. I am in season three of the show. At this
point in the show the forensic technician Abby and Special Agent McGee, are always coming up with
new algorithms to enhance images received from security cameras and satellites. Some of these
algorithms are realistic, others are well, made for TV.
One easy adjustment to an image that might help you make see what is in the image is to brighten it.
Brightening an image is easy. You simply add a constant value to the red, green, and blue value of each
pixel in the image. The larger the constant, the brighter the resulting image.
Here is a picture I took one night in my backyard:
You really cannot make out a lot in the picture. You can see the railing on my deck, and if you look hard
enough you can see my shed in the upper right-hand corner of the photo.
Applying the “brightening” algorithm I described above, using a constant of 100, results in the image
below:
In this image you can see that there were two deer in my yard that night. These were the criminals that
were raiding my garden every night.
If you brighten a picture too much, you get a washed-out image. Here is that same image but brightened
by 200:
Here almost all the details of the picture have been brightened to the point where you cannot see them.
About the only thing you can see are the trees at the back of the yard, and if you look hard you can start
to make out the houses on the other side of my yard.
For this activity, write a program that will brighten an image. Start with one of the programs you wrote
in the previous two labs (the gray scale program might be a good starting point). The only trick to this
program is remember that a color value cannot be greater than 255 (8-bit color remember?). After you
brighten the color values for a pixel, before putting the new colors in the image, check to see if any color
value exceeds 255. If a value exceeds 255, set that value to 255 since that is the maximum possible RGB
value. If you read these words carefully you should be able to see exactly what you need to do in your
program ����
Note that you can darken images as well. To darken you subtract a constant value from each color in the
pixels. Here you need to make sure none of the resulting colors are negative, if they are you would set
them to zero. I tell you this only if you happen to find yourself working in a crime lab and need to darken
an image for the “boss!!”
Name the file that contains your program lab5-act4.py.
Explanations and Answers
0
No answers posted
Post your Answer - free or at a fee
NB: Post a homework question for free and get answers - free or paid homework help.
Get answers to: Computer Science 100 Class Lab or similar questions only at Tutlance.
Related Questions
- Use Turtle Graphics To Draw A Mickey Mouse Head On Python
- Use Turtle Graphics To Draw A Mickey Mouse Head On Python
- Use Turtle Graphics To Draw A Mickey Mouse Head On Python
- Two Data Science Problems Involving Python Notebooks
- Two Data Science Problems Involving Python Notebooks
- Do You Provide Help With College Admissions Essays
- Sas Performing Basic Sas Programing
- The Question Is About A Homework Problem Related To College Grading Book, Details Are Attached Below.
- The Question Is About A Homework Problem Related To College Grading Book, Details Are Attached Below.
- Nursing Statistics Using Stata
- Python Number Guessing Game. I Did The Basic Code But I Keep Getting Errors While Calling The Code
- Color Palette Using Arduino Uno And Processing
- Webgl Program(Javascript File).
- Need 2 Simple Python Programs Based On Lab Exercise.
- Write A Complete Program That Will Do The Steps
- Python Project Program Will Read Files Produced By A High-Throughput Sequencer — A Machine That Takes As Input Some Dna
- Neo4J And Python Programming Tasks In Big Data Tecnologies
- Business Statistics Data Analyst
- Decision Making Analytics Excel Hw
- Decision Making Analytics Excel Hw
- Basic Coding Question (Python)
- Data Cleaning, Binning, Encoding, Feature Engineering
- Data Cleaning, Binning, Encoding, Feature Engineering
- Data Cleaning, Binning, Feature Engineering, Encoding
- Quantitative Research Analysis
- Can You Help Me Do This Assignment?
- Computer Vision Sift Assignment
- Language Proficiency Scores Programming
- Language Proficiency Scores Programming
- I Need Help Making Maps Of Pompano Beach, Fl On Arc Gis Pro
- I Need Help Making Maps Of Pompano Beach, Fl On Arc Gis Pro
- Console Application
- Build Gui Using Java Language For Snake Game And Ship Simulators.
- Common App Personal Essay Of Your Choice
- Matlab Hw Need S To Be Done By 1030 Tomorrow Please
- Mixed Models Online Exam - Stats + R
- Mixed Models Online Exam - Stats + R
- Streaming Log Analytics ( Only Open Source Tools To Be Used For Data Pipeline)
- Using Python Computing Services
- Using Python Computing Services
- Assignment To Write A C Program That Implements A Singly Linked List
- Write An R Programming Assignment On Factor Analysis
- Classification With Glms, Trees, Svms
- Python/R Script To Evaluate Several Files
- Java Assgiment Help And Tutoring
- Java Assgiment Help And Tutoring
- Python/R Script To Evaluate Several Files
- Python/R Script To Evaluate Several Files
- Coding Homework C++ Classes, Read, Constructer Etc
- Tableau And Excel Assignment Lending Analysis..........