Free Essay

Fricking

In:

Submitted By sukadikchikin
Words 1038
Pages 5
Chapter 3
Complete coding questions 14, 15, and 16 from chapter 3. Each question should be commented and created as a self-named function (fourteen, fifteen, and sixteen) in a file called chapter3.py.
14. Write a program that finds the average of a series of numbers entered by the user. As in the previous problem, the program will first ask the user how many numbers there are. Note: the average should always be a float, even if the user inputs are all ints.
15. Write a program that approximates the value of π by summing the terms of this series: 4/1 − 4/3 + 4/5 − 4/7 + 4/9 − 4/11 + . . . The program should prompt the user for n, the number of terms to sum, and then output the sum of the first n terms of this series. Have your program subtract the approximation from the value of math.pi to see how accurate it is.
16. A Fibonacci sequence is a sequence of numbers where each successive number is the sum of the previous two. The classic Fibonacci sequence begins: 1, 1, 2, 3, 5, 8, 13,. . .. Write a program that computes the nth Fibonacci number where n is a value input by the user. For example, if n = 6, then the result is 8.

Chapter 4
Please complete the coding questions 4, 10, and 11 at the end of the chapter. Each question is implemented as its own function using its numbered name (ex question 4 to be called four()) and all three functions to be included in one file called chpt4.py.
4. Write a program that draws a winter scene with a Christmas tree and a snowman.

10. Triangle Information. Same as previous problem, but with 3 clicks for the vertices of a triangle.
9. Triangle Information. This program displays information about a triangle drawn by the user.
Input: 3 mouse clicks for the opposite corners of a triangle.
Output: Draw the rectangle. Print the perimeter and area of the triangle.

11. Five-click house.
You are to write a program that allows the user to draw a simple house using five mouse clicks. The first two clicks will be the opposite corners of the rectangular frame of the house. The third click will indicate the center of the top edge of a rectangular door. The door should have a total width that is 1/5 of the width of the house frame. The sides of the door should extend from the corners of the top down to the bottom of the frame. The fourth click will indicate the center of a square window. The window is half as wide as the door. The last click will indicate the peak of the roof. The edges of the roof will extend from the point at the peak to the corners of the top edge of the house frame.

Chapter 5
Complete all odd coding questions at the end of chapter 5. Be sure to answer each question as a single method named as the written number (ex. question 1 = def one():) and include all questions in one file named chpt5.py.
1. As discussed in the chapter, string formatting could be used to simplify the dateconvert2.py program. Go back and redo this program making use of the string-formatting method.
3. A certain CS professor gives 100-point exams that are graded on the scale 90–100:A, 80–89:B, 70–79:C, 60–69:D,

5. Numerologists claim to be able to determine a person’s character traits based on the “numeric value” of a name. The value of a name is determined by summing up the values of the letters of the name where ’a’ is 1, ’b’ is 2, ’c’ is 3 etc., up to ’z’ being 26. For example, the name “Zelle” would have the value 26+ 5+ 12+ 12+ 5 = 60 (which happens to be a very auspicious number, by the way). Write a program that calculates the numeric value of a single name provided as input.

7. A Caesar cipher is a simple substitution cipher based on the idea of shifting each letter of the plaintext message a fixed number (called the key) of positions in the alphabet. For example, if the key value is 2, the word “Sourpuss” would be encoded as “Uqwtrwuu.” The original message can be recovered by “reencoding” it using the negative of the key.
Write a program that can encode and decode Caesar ciphers. The input to the program will be a string of plaintext and the value of the key. The output will be an encoded message where each character in the original message is replaced by shifting it key characters in the Unicode character set. For example, if ch is a character in the string and key is the amount to shift, then the character that replaces ch can be calculated as: chr(ord(ch) + key).

9. Write a program that counts the number of words in a sentence entered by the user

11. Write an improved version of the Chaos program from Chapter 1 that allows a user to input two initial values and the number of iterations and then prints a nicely formatted table showing how the values change over time. For example, if the starting values were .25 and .26 with 10 iterations, the table might look like this:

13. Redo any of the previous programming problems to make them batch oriented (using text files for input and output).

15. Write a program to plot a horizontal bar chart of student exam scores. Your program should get input from a file. The first line of the file contains the count of the number of students in the file, and each subsequent line contains a student’s last name followed by a score in the range 0 to 100. Your program should draw a horizontal rectangle for each student where the length of the bar represents the student’s score. The bars should all line up on their lefthand edges. Hint: use the number of students to determine the size of the window and its coordinates. Bonus: label the bars at the left end with the student name.

Similar Documents

Premium Essay

The Absolutely True Diary Of A Part Time Indian Analysis

...white in order to succeed in life. Therefore, the first cartoon depicts his hope, as he is an artist. It shows that though he has a home in reservation, what he would do after he has gone to the outer world of hope and success, he does not now about it. The question mark given here in the cartoon shows his conflict that he has to go through and will have to go through. However, at Reardan, he is after Penelope with whom he is in love. This is also a desire to be recognized as more than an Indian as she cannot love him in his present shape and circumstances because his friend Rowdy has clearly told him that " The first thing you have to do is change the way you look, the way you talk, and the way you walk. And then she'll think you're her fricking Prince Charming" (65) that he knows he is not, but the conflict over being loved or not is...

Words: 1473 - Pages: 6

Free Essay

Canda Through the Decade 80s

...Politics, Economy, & International Relation­ Sai    Quebec votes “no” to Sovereignty Association Pg 374  On May 15, 1980 a vote was taken for those who wanted  quebec to be a country of its own or stay within Canada.  This topic arouse by Rene Levesque because he believed  the French language and culture was being ignored, he also  believed quebec was not supported by the federal  government. Rene Levesque was for an independent  country but Prime Minister Trudeau wanted all provinces to  stay together to uphold Canada's unity. With the  disappointing loss of the votes another referendum was  promised.    National Energy Program (NEP) is Established Pg 401  In 1980 the Federal government took further steps to  ensure Canadian control of energy supplies. Thus the  National Energy Program is introduced. Their goal was to  establish 50% Canadian ownership of the Canadian oil and  gas industry, to make Canada self sufficient in energy by  1990 and to control oil prices. American oil companies were  provoked with Canada's progress which lead American  companies to pull many of their drilling rigs out of Canada  leaving many unemployed, mainly in the western region.  The NEP caused a big divide between Ottawa and Western  provinces.     Constitution Act is Signed by Queen Elizabeth Pg 375  On April 17, 1982 the Constitution Act was signed. Before  this act any changes required the approval of the British  government because of the British North America Act...

Words: 1623 - Pages: 7

Premium Essay

Junk

...Politics, Economy, & International Relation- Sai Quebec votes “no” to Sovereignty Association Pg 374 On May 15, 1980 a vote was taken for those who wanted quebec to be a country of its own or stay within Canada. This topic arouse by Rene Levesque because he believed the French language and culture was being ignored, he also believed quebec was not supported by the federal government. Rene Levesque was for an independent country but Prime Minister Trudeau wanted all provinces to stay together to uphold Canada's unity. With the disappointing loss of the votes another referendum was promised. National Energy Program (NEP) is Established Pg 401 In 1980 the Federal government took further steps to ensure Canadian control of energy supplies. Thus the National Energy Program is introduced. Their goal was to establish 50% Canadian ownership of the Canadian oil and gas industry, to make Canada self sufficient in energy by 1990 and to control oil prices. American oil companies were provoked with Canada's progress which lead American companies to pull many of their drilling rigs out of Canada leaving many unemployed, mainly in the western region. The NEP caused a big divide between Ottawa and Western provinces. Constitution Act is Signed by Queen Elizabeth Pg 375 On April 17, 1982 the Constitution Act was signed. Before this act any changes required the approval of the British government because of the British North America Act. Trudeau took action to make Canada a more independent...

Words: 1621 - Pages: 7

Premium Essay

Onnie

...Title: Eric Clapton - Tears In Heaven lyrics Would you know my name If I saw you in heaven Will it be the same If I saw you in heaven I must be strong, and carry on Cause I know I don't belong Here in heaven Would you hold my hand If I saw you in heaven Would you help me stand If I saw you in heaven I'll find my way, through night and day Cause I know I just can't stay Here in heaven Time can bring you down Time can bend your knee Time can break your heart Have you begging please Begging please (instrumental) Beyond the door There's peace I'm sure. And I know there'll be no more... Tears in heaven Would you know my name If I saw you in heaven Will it be the same If I saw you in heaven I must be strong, and carry on Cause I know I don't belong Here in heaven Cause I know I don't belong Here in heaven Title: David Archuleta - Crush lyrics Deep inside It was a rush What a rush 'Cause the possibility That you would ever feel the same way About me It's just too much Just too much Why do I keep running from the truth All I ever think about is you You got me hypnotized So mesmerized And I've just got to know [chorus:] Do you ever think When you're all alone All that we could be? Where this thing could go? Am I crazy or falling in love? Is it really just another crush? Do you catch a breath When I look at you? Are you holding back Like the way I do? 'Cause I'm trying, trying to...

Words: 18902 - Pages: 76

Premium Essay

The Blak Dagger Brotherhood

...Color-- -1- -2- -3- -4- -5- -6- -7- -8- -9- Text Size-- 10-- 11-- 12-- 13-- 14-- 15-- 16-- 17-- 18-- 19-- 20-- 21-- 22-- 23-- 24 Dark Lover A Novel of the Black Dagger Brotherhood By J.R. Ward Contents Chapter One Chapter Two Chapter Three Chapter Four Chapter Five Chapter Six Chapter Seven Chapter Eight Chapter Nine Chapter Ten Chapter Eleven Chapter Twelve Chapter Thirteen Chapter Fourteen Chapter Fifteen Chapter Sixteen Chapter Seventeen Chapter Eighteen Chapter Nineteen Chapter Twenty Chapter Twenty-one Chapter Twenty-two Chapter Twenty-three Chapter Twenty-four Chapter Twenty-five Chapter Twenty-six Chapter Twenty-seven Chapter Twenty-eight Chapter Twenty-nine Chapter Thirty Chapter Thirty-one Chapter Thirty-two Chapter Thirty-three Chapter Thirty-four Chapter Thirty-five Chapter Thirty-six Chapter Thirty-seven Chapter Thirty-eight Chapter Thirty-nine Chapter Forty Chapter Forty-one Chapter Forty-two Chapter Forty-three Chapter Forty-four Chapter Forty-five Chapter Forty-six Chapter Forty-seven Chapter Forty-eight Chapter Forty-nine Chapter Fifty Chapter Fifty-one Chapter Fifty-two Chapter Fifty-three Chapter Fifty-four Chapter Fifty-five Epilogue A dangerous passion… Wrath walked into the hall, feeling particularly ferocious. Man, Beth had better be alive and well. Or God help whoever had hurt her. And if she'd decided to avoid him? That didn't matter. Her body was about to need something only he could provide her. So sooner or later she would come...

Words: 121508 - Pages: 487

Free Essay

Me Before You

...Jojo Moyes a fter you Contents CHAPTER ONE CHAPTER TWO CHAPTER THREE CHAPTER FOUR CHAPTER FIVE CHAPTER SIX CHAPTER SEVEN CHAPTER EIGHT CHAPTER NINE CHAPTER TEN CHAPTER ELEVEN CHAPTER TWELVE CHAPTER THIRTEEN CHAPTER FOURTEEN CHAPTER FIFTEEN CHAPTER SIXTEEN CHAPTER SEVENTEEN CHAPTER EIGHTEEN CHAPTER NINETEEN CHAPTER TWENTY CHAPTER TWENTY-ONE CHAPTER TWENTY-TWO CHAPTER TWENTY-THREE CHAPTER TWENTY-FOUR CHAPTER TWENTY-FIVE CHAPTER TWENTY-SIX CHAPTER TWENTY-SEVEN CHAPTER TWENTY-EIGHT CHAPTER TWENTY-NINE CHAPTER THIRTY ACKNOWLEDGEMENTS FOLLOW PENGUIN For my grandmother, Betty McKee chapter one The big man at the end of the bar is sweating. He holds his head low over his double Scotch, but every few minutes he glances up and out, behind him, towards the door. A fine sheen of perspiration glistens under the strip-lights. He lets out a long, shaky breath, disguised as a sigh, and turns back to his drink. ‘Hey. Excuse me?’ I look up from polishing glasses. ‘Can I get another one here?’ I want to tell him it’s really not a good idea, it won’t help, it might even put him over the limit. But he’s a big guy and it’s fifteen minutes till closing time and, according to company guidelines, I have no reason to tell him no, so I walk over, take his glass and hold it up to the optic. He nods at the bottle. ‘Double,’ he says, and slides a fat hand down his damp face. ‘That’ll be seven pounds twenty, please.’ It’s a quarter to eleven on a Tuesday night and the Shamrock and Clover, East City...

Words: 120665 - Pages: 483