Part 1: Framed BoxIn this part, we will solve a framing problem similar to Lab 2.Write a program that asks the user for the width and height of a framed box, and the characterto use in the frame. Then, display a box of the given size, framed by the given character. Also,display the dimensions of the box inside the second line of the box (just after the left frame and aspace).Assume that the user inputs valid values for each input: width is a positive integer (7 or higher)and height is a positive integer (4 or higher), and a single character is given for the frame.Here is an expected output of your program (how it will look on the homework submission server):Width of box == 7Height of box == 4Enter frame character == @Box:@@@@@@@@ 74 @@ @@@@@@@@Here is another possible output:Width of box == 12Height of box == 8Enter frame character == #Box:############# 128 ## ## ## ## ## #############This is in essence very similar to the lab, except that you will need to put the box dimensions intake a <adjective <noun and think things over I know Ive made some very <adjective decisions recently,but I can give you my complete <noun that my work will be backto <adjective.You will ask the missing pieces of the following madlib to the user using the (raw_input) functionwe learnt in class on thursday. For each input, you will ask the specific type of word required.You will then take all the user specified inputs, and construct the above madlib. You can use anystring method we have learnt. Make sure your output looks like the above paragraph, except thatthe missing information is filled in with the user input. Here is an example run of the program(how it will look at the homework submission server):proper name == Brademotion == happyverb == eatadjective == sillynoun == mouseadjective == hungrynoun == computeradjective == cuteHere is your output:Look, Brad I can see youre really happy about this I honestly think you ought to eat calmly take a silly mouse and think things over I know Ive made some very hungry decisions recently,but I can give you my complete computer that my work will be backto cute.When you have tested your code and sure that it works, please submit it as hw1_part2.py.Part 3: Name popularityHow popular were different names in different decades? Which names have increased or decreasedin popularity? We can actually find out thanks to the various real data sets available these days.This homework will be based on real data, but we only ask you to read the numbers for one nameusing raw_input().Write a program that reads the number of babies born with a specific name in decades: 1970,1980, 1990 and 2000. You must then print the information using a table like the one below. Then,compute the percent change in popularity between each consecutive decade. Print this informationand the average percent difference.You will need to use formatted strings for this to look correct. If you want to print percent sign %in a formatted string, you need to escape it by writing it twice. Here is an example:print The decrease: %% %.2f %(12.345678)The decrease: % 12.35Here is an example output of the program for name Anya (how it will look on the homeworksubmission server):Please enter a name == AnyaCount in 1970 = 520Count in 1980 = 1326Count in 1990 = 1495Count in 2000 = 6875Babies named Anya*****************Year / Total / % change from previous decade1970 / 5201980 / 1326 / % 155.001990 / 1495 / % 12.752000 / 6875 / % 359.87Average change: % 175.87How are the above percentage values computed? Let us look the first value: 155 = 100*(1326-520)/520Basically, in 1980s, there was an increase of 1326-520=806 for this name. How big is this valuecompared to the original 520? We find this by computing 100*806/520.Note that for this part, we are not trying to produce a very polished output and we will not aligncolumns in the table for decades. We simply have a single space and slash (/) after each value.Assume no zero values for any decade (so you will not get division by zero errors).This is a relatively long program, but it is also repetitive. Let us try to employ the principle ofiterative programming to solve it. First, write a program to read one input and print it. What is a good name for your variable? Now, add another line to read the next input, print it. Also, compute the percentage changefrom the previous one. Print this as well. Look at formatting. How do you print only two digits after comma? How do you print thepercent sign? Fix it. Now, worry about reading the name and print it. Also figure out how many stars to print inthe next line. How many are needed, given the length of the name? Now, add all the percentage values and divide by three to find the average. Display this value. You are not done yet! Dont forget an important part. TESTING! Test with some simplevalues: 1,2,4,8 and 1,2,6,24 (and decreasing values as well). What do you expect to see? Doyou match? Now, try some more challenging values.When you have tested your code, please submit it as hw1_part3.py
CSCI1100
[Solved] CSCI1100 Homework 1 Calculations and Strings
$25
File Name: CSCI1100_Homework_1_Calculations_and_Strings.zip
File Size: 414.48 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.