44 1 Computing with formulas, calculator or one can apply the program to a special simple test case. with known results The requirement is to provide evidence to the claim. that the program is without programming errors, The sample run of the program to check its correctness can be inserted. at the end of the program as a triple quoted string Alternatively the. output lines can be inserted as comments but using a multi line string. requires less typing Technically a string object is created but not. assigned to any name or used for anything in the program beyond. providing useful information for the reader of the code One can do. Terminal python myprogram py result, and use a text editor to insert the le result inside the triple quoted. multi line string Here is an example on a run of a Fahrenheit to Celsius. conversion program inserted at the end as a triple quoted string. F 69 8 Fahrenheit degrees,C 5 0 9 F 32 Corresponding Celsius degrees. Sample run correct result is 21,python f2c py,Exercise 1 1 Compute 1 1. The rst exercise concerns some very basic mathematics and program. ming assign the result of 1 1 to a variable and print the value of that. variable Filename 1plus1 py,Exercise 1 2 Write a Hello World program. Almost all books about programming languages start with a very simple. program that prints the text Hello World to the screen Make such a. program in Python Filename hello world py,Exercise 1 3 Derive and compute a formula. Can a newborn baby in Norway expect to live for one billion 109. seconds Write a Python program for doing arithmetics to answer the. question Filename seconds2years py,1 9 Exercises 45. Exercise 1 4 Convert from meters to British length units. Make a program where you set a length given in meters and then compute. and write out the corresponding length measured in inches in feet in. yards and in miles Use that one inch is 2 54 cm one foot is 12 inches. one yard is 3 feet and one British mile is 1760 yards For veri cation a. length of 640 meters corresponds to 25196 85 inches 2099 74 feet 699 91. yards or 0 3977 miles Filename length conversion py. Exercise 1 5 Compute the mass of various substances. The density of a substance is de ned as m V where m is the mass. of a volume V Compute and print out the mass of one liter of each of. the following substances whose densities in g cm3 are found in the le. src files densities dat6 iron air gasoline ice the human body. silver and platinum Filename 1liter py, Exercise 1 6 Compute the growth of money in a bank. Let p be a bank s interest rate in percent per year An initial amount A. has then grown to, after n years Make a program for computing how much money 1000 euros. have grown to after three years with 5 percent interest rate Filename. interest rate py,Exercise 1 7 Find error s in a program. Suppose somebody has written a simple one line program for computing. x 1 print sin g g x sin x, Create this program and try to run it What is the problem. Exercise 1 8 Type in program text, Type the following program in your editor and execute it If your program. does not work check that you have copied the code correctly. http tinyurl com pwyasaa files densities dat,46 1 Computing with formulas. from math import pi,h 5 0 height,b 2 0 base,r 1 5 radius. area parallelogram h b, print The area of the parallelogram is 3f area parallelogram. area square b 2,print The area of the square is g area square. area circle pi r 2,print The area of the circle is 3f area circle. volume cone 1 0 3 pi r 2 h,print The volume of the cone is 3f volume cone. Filename formulas shapes py,Exercise 1 9 Type in programs and debug them. Type these short programs in your editor and execute them When they. do not work identify and correct the erroneous statements. a Does sin2 x cos2 x 1,from math import sin cos,1 val math sin 2 x math cos 2 x. print 1 VAL, b Compute s in meters when s v0 t 12 at2 with v0 3 m s t 1 s. s v0 t 0 5 a t 2,c Verify these equations,a b 2 a2 2ab b2. a b 2 a2 2ab b2,a 3 3 b 5 3,eq1 sum a2 2ab b2,eq2 sum a2 2ab b2. eq1 pow a b 2,1 9 Exercises 47,eq2 pow a b 2,print First equation g g eq1 sum eq1 pow. print Second equation h h eq2 pow eq2 pow,Filename sin2 plus cos2 py. Exercise 1 10 Evaluate a Gaussian function,The bell shaped Gaussian function. f x exp 1 7, is one of the most widely used functions in science and technology The. parameters m and s 0 are prescribed real numbers Make a program. for evaluating this function when m 0 s 2 and x 1 Verify the. program s result by comparing with hand calculations on a calculator. Filename gaussian1 py, Remarks The function 1 7 is named after Carl Friedrich Gauss7 1777. 1855 who was a German mathematician and scientist now considered as. one of the greatest scientists of all time He contributed to many elds. including number theory statistics mathematical analysis di erential ge. ometry geodesy electrostatics astronomy and optics Gauss introduced. the function 1 7 when he analyzed probabilities related to astronomical. Exercise 1 11 Compute the air resistance on a football. The drag force due to air resistance on an object can be expressed as. Fd CD AV 2 1 8, where is the density of the air V is the velocity of the object A is. the cross sectional area normal to the velocity direction and CD is the. drag coe cient which depends heavily on the shape of the object and. the roughness of the surface, The gravity force on an object with mass m is Fg mg where. g 9 81m s 2, We can use the formulas for Fd and Fg to study the importance of. air resistance versus gravity when kicking a football The density of air. is 1 2 kg m 3 We have A a2 for any ball with radius a For a. football a 11 cm the mass is 0 43 kg and CD can be taken as 0 2. http en wikipedia org wiki Carl Gauss,48 1 Computing with formulas. Make a program that computes the drag force and the gravity force. on a football Write out the forces with one decimal in units of Newton. N kg m s2 Also print the ratio of the drag force and the gravity force. De ne CD A V m g Fd and Fg as variables and put a comment. with the corresponding unit Use the program to calculate the forces on. the ball for a hard kick V 120 km h and for a soft kick V 10 km h. it is easy to mix inconsistent units so make sure you compute with V. expressed in m s Filename kick py,Exercise 1 12 How to cook the perfect egg. As an egg cooks the proteins rst denature and then coagulate When. the temperature exceeds a critical point reactions begin and proceed. faster as the temperature increases In the egg white the proteins start. to coagulate for temperatures above 63 C while in the yolk the proteins. start to coagulate for temperatures above 70 C For a soft boiled egg. the white needs to have been heated long enough to coagulate at a. temperature above 63 C but the yolk should not be heated above 70 C. For a hard boiled egg the center of the yolk should be allowed to reach. The following formula expresses the time t it takes in seconds for. the center of the yolk to reach the temperature Ty in Celsius degrees. M 2 3 c 1 3 To T w,t ln 0 76 1 9,2 2 3 Ty T w, Here M c and K are properties of the egg M is the mass is the. density c is the speci c heat capacity and K is thermal conductivity. Relevant values are M 47 g for a small egg and M 67 g for a large egg. 1 038 g cm 3 c 3 7 J g 1 K 1 and K 5 4 10 3 W cm 1 K 1. Furthermore Tw is the temperature in C degrees of the boiling water. and To is the original temperature in C degrees of the egg before being. put in the water Implement the formula in a program set Tw 100. C and Ty 70 C and compute t for a large egg taken from the fridge. To 4 C and from room temperature To 20 C Filename egg py. Exercise 1 13 Derive the trajectory of a ball, The purpose of this exercise is to explain how Equation 1 6 for the. trajectory of a ball arises from basic physics There is no programming. in this exercise just physics and mathematics, The motion of the ball is governed by Newton s second law. 1 9 Exercises 49,Fx max 1 10,Fy may 1 11, where Fx and Fy are the sum of forces in the x and y directions respec. tively ax and ay are the accelerations of the ball in the x and y directions. and m is the mass of the ball Let x t y t be the position of the ball. i e the horizontal and vertical coordinate of the ball at time t There. are well known relations between acceleration velocity and position the. acceleration is the time derivative of the velocity and the velocity is the. time derivative of the position Therefore we have that. If we assume that gravity is the only important force on the ball Fx 0. Integrate the two components of Newton s second law twice Use the. initial conditions on velocity and position,x 0 v0 cos 1 14. y 0 v0 sin 1 15,x 0 0 1 16,y 0 y0 1 17, to determine the four integration constants Write up the nal expressions. for x t and y t Show that if 2 i e the motion is purely vertical. we get the formula 1 1 for the y position Also show that if we eliminate. t we end up with the relation 1 6 between the x and y coordinates. of the ball You may read more about this type of motion in a physics. book e g 16 Filename trajectory, Exercise 1 14 Find errors in the coding of formulas. Some versions of our program for calculating the formula 1 3 are listed. below Find the versions that will not work correctly and explain why in. C 21 F 9 5 C 32 print F,C 21 0 F 9 5 C 32 print F,C 21 0 F 9 C 5 32 print F. C 21 0 F 9 C 5 0 32 print F,C 21 0 F 9 0 C 5 0 32 print F. 50 1 Computing with formulas,C 21 F 9 C 5 32 print F. C 21 0 F 1 5 9 C 32 print F,C 21 F 1 5 9 C 32 print F. Exercise 1 15 Explain why a program does not work,Find out why the following program does not work. Exercise 1 16 Find errors in Python statements, Try the following statements in an interactive Python shell Explain why. some statements fail and correct the errors,y X 4 is it 6. from Math import tan,print tan pi,pi 3 14159,print tan pi. c 78564 c 32,discount 12,AMOUNT 120,amount 120,address hpl simula no. class INF1100 gr 2,continue x 0,rev fox True,Norwegian a human language. true fox is rev in Norwegian, Hint It is wise to test the values of the expressions on the right hand. side and the validity of the variable names separately before you put the. left and right hand sides together in statements The last two statements. work but explaining why goes beyond what is treated in this chapter. Exercise 1 17 Find errors in the coding of a formula. Given a quadratic equation,ax2 bx c 0,the two roots are. 1 9 Exercises 51,b b2 4ac b b2 4ac,x1 x2 1 18,What are the problems with the following program. a 2 b 1 c 2,from math import sqrt,q b b 4 a c,q sr sqrt q. x1 b q sr 2 a,x2 b q sr 2 a,print x1 x2, Correct the program so that it solves the given equation Filename. find errors roots py,84 2 Loops and lists, Quick references which list almost to all Python functionality in. compact tabular form are very handy We recommend in particular the. one by Richard Gruet6 6, The website http www python org doc contains a list of useful. Python introductions and reference manuals,2 7 Exercises. Exercise 2 1 Make a Fahrenheit Celsius conversion table. Write a Python program that prints out a table with Fahrenheit degrees. 0 10 20 100 in the rst column and the corresponding Celsius degrees. in the second column, Hint Modify the c2f table while py program from Section 2 1 2. Filename f2c table while py, Exercise 2 2 Generate an approximate Fahrenheit Celsius. conversion table, Many people use an approximate formula for quickly converting Fahren. heit F to Celsius C degrees,C C F 30 2 2 2, Modify the program from Exercise 2 1 so that it prints three columns. F C and the approximate value C Filename f2c approx table py. Exercise 2 3 Work with a list, Set a variable primes to a list containing the numbers 2 3 5 7 11 and. 13 Write out each list element in a for loop Assign 17 to a variable p. and add p to the end of the list Print out the entire new list Filename. Exercise 2 4 Generate odd numbers, Write a program that generates all odd numbers from 1 to n Set n in the. beginning of the program and use a while loop to compute the numbers. Make sure that if n is an even number the largest generated odd number. is n 1 Filename odd py,http rgruet free fr PQR27 PQR2 7 html. 2 7 Exercises 85,Exercise 2 5 Sum of rst n integers. Write a program that computes the sum of the integers from 1 up to and. including n Compare the result with the famous formula n n 1 2. Filename sum int py,Exercise 2 6 Generate equally spaced coordinates. We want to generate n 1 equally spaced x coordinates in a b Store. the coordinates in a list, a Start with an empty list use a for loop and append each coordinate. to the list, Hint With n intervals corresponding to n 1 points in a b each. interval has length h b a n The coordinates can then be generated. by the formula xi a ih i 0 n 1,b Use a list comprehension see Section 2 3 5. Filename coor py, Exercise 2 7 Make a table of values from a formula. The purpose of this exercise is to write code that prints a nicely formatted. table of t and y t values where,y t v0 t gt2, Use n 1 uniformly spaced t values throughout the interval 0 2v0 g. a Use a for loop to produce the table,b Add code with a while loop to produce the table. Hint Because of potential round o errors you may need to adjust the. upper limit of the while loop to ensure that the last point t 2v0 g. y 0 is included,Filename ball table1 py,Exercise 2 8 Store values from a formula in lists. This exercise aims to produce the same table of numbers as in Exercise 2 7. but with di erent code First store the t and y values in two lists t and. y Thereafter write out a nicely formatted table by traversing the two. lists with a for loop, Hint In the for loop use either zip to traverse the two lists in parallel. or use an index and the range construction,Filename ball table2 py. 86 2 Loops and lists,Exercise 2 9 Simulate operations on lists by hand. You are given the following program,a 1 3 5 7 11,d e 1 for e in a. d append b 0 1,d append b 1 1,for e1 in a,for e2 in b. print e1 e2, Go through each statement and explain what is printed by the program. Exercise 2 10 Compute a mathematical sum, The following code is supposed to compute the sum s k 1 k. s 0 k 1 M 100, This program does not work correctly What are the three errors If you. try to run the program nothing will happen on the screen Type Ctrl c. i e hold down the Control Ctrl key and then type the c key to stop. the program Write a correct program, Hint There are two basic ways to nd errors in a program. 1 read the program carefully and think about the consequences of each. 2 print out intermediate results and compare with hand calculations. First try method 1 and nd as many errors as you can Thereafter try. method 2 for M 3 and compare the evolution of s with your own hand. calculations,Filename sum while py,Exercise 2 11 Replace a while loop by a for loop. Rewrite the corrected version of the program in Exercise 2 10 using a. for loop over k values instead of a while loop Filename sum for py. 2 7 Exercises 87,Exercise 2 12 Simulate a program by hand. Consider the following program for computing with interest rates. initial amount 100,p 5 5 interest rate,amount initial amount. while amount 1 5 initial amount,amount amount p 100 amount. years years 1,print years, a Use a pocket calculator or an interactive Python shell and work. through the program calculations by hand Write down the value of. amount and years in each pass of the loop, b Set p 5 instead Why will the loop now run forever Apply Ctrl c. see Exercise 2 10 to stop a program with a loop that runs forever Make. the program robust against such errors, c Make use of the operator wherever possible in the program. d Explain with words what type of mathematical problem that is solved. by this program,Filename interest rate loop py,Exercise 2 13 Explore Python documentation. Suppose you want to compute with the inverse sine function sin 1 x. How do you do that in a Python program, Hint The math module has an inverse sine function Find the correct. name of the function by looking up the module content in the online. Python Standard Library7 document or use pydoc see Section 2 6 3. Filename inverse sine py,Exercise 2 14 Index a nested lists. We de ne the following nested list,q a b c d e f g h. a Index this list to extract 1 the letter a 2 the list d e f. 3 the last element h 4 the d element Explain why q 1 2 has the. b We can visit all elements of q using this nested for loop. http docs python org 2 library,88 2 Loops and lists. for i in q,for j in range len i,What type of objects are i and j. Filename index nested list py,Exercise 2 15 Store data in lists. Modify the program from Exercise 2 2 so that all the F C and C values. are stored in separate lists F C and C approx respectively Then make. a nested list conversion so that conversion i holds a row in the. table F i C i C approx i Finally let the program traverse. the conversion list and write out the same table as in Exercise 2 2. Filename f2c approx lists py,Exercise 2 16 Store data in a nested list. a Compute two lists of t and y values as explained in Exercise 2 8. Store the two lists in a new nested list ty1 such that ty1 0 and ty1 1. correspond to the two lists Write out a table with t and y values in two. columns by looping over the data in the ty1 list Each number should. be written with two decimals, b Make a list ty2 which holds each row in the table of t and y values. ty1 is a list of table columns while ty2 is a list of table rows as explained. in Section 2 4 Loop over the ty2 list and write out the t and y values. with two decimals each,Filename ball table3 py,Exercise 2 17 Values of boolean expressions. Explain the outcome of each of the following boolean expressions. C 40 and C 41,C 40 or C 41,True and False,False or True.

Introduction To The Free eBook ... The Skin Deep Program is different and has worked dramatically even for people who have gotten nowhere with other treatments. This book is designed to give you helpful information and be an active part of your healing process. I suggest reading slowly. Let the book stir up thoughts, memories, and feelings. Thinking about the diagnostic exercises is helpful ...

The Macmillan Science series is a comprehensive science course for all students in primary schools. Building on practical experience and investigation, the books follow current best practice in science education. Through engaging content and carefully graded activities and exercises, students are guided to develop a

Study of Education, entitled, T/ie Meas urement of Understanding, and distrib uted by the University of Chicago Press. 1 Information and understanding may be measured informally by teacher-made tests using multiple choice, true-false, or completion types of test items and exercises. Work-study skills may be as

Dignitary and Executive Protection Specialist Program ISA 101 Module One Basic Core Training Program Law Enforcement and University Accredited Ver; Jan 1, 2017 (7 Days) (80 hrs.) 48 Learning objectives 14 Practical exercises 3 facilitated discussions live capstone Faculty Information Matthew C. Parker Program Director 315-486-7854

We begin our tour of mathematics for physics with what is called the calculus of variations. Many physics problems can be formulated in the language of this calculus, and once they are there are useful tools to hand. In the text and associated exercises we will meet some of the equations whose solution will occupy us for much of our journey.

2012 Soil Mechanics I and Exercises Final Examination 2013/1/22 (Tue) 13:00 - 15:00 Kyotsu 155?Kyotsu 1?Kyotsu 3?W2 Lecture room Attention: There are four questions and four answer sheets. Write down your name and ID number on every answer sheet. Use one answer sheet for one question and answer in sequence from ?Question 1?. If the ...

as prevention of infecting people outside of the laboratory, such as your friends and family. These techniques can be applied not only here in the microbiology laboratory, but also throughout your career, and in your daily life. Most of the laboratory exercises performed in this course will involve a two-step process. During the lab session

Solutions to Exercises in Modern Condensed Matter Physics S. M. Girvin and Kun Yang c 2019 [Compiled: August 12, 2019] Note to Instructors For a few of the more di cult problems, we include notes to the instructor suggesting simpli cations, specializations and hints that the instructor may wish to give the students when assigning those problems. Note also that there are some useful exercises ...

Structured Programming in Python 5.1 Introduction In Part I you had an intensive introduction to Python (Chapter 1) followed by chapters on words, tags, and chunks (Chapters 2-6). These chapters contain many examples and exercises that should have helped you consolidate your Python skills and apply them to simple NLP tasks. So far our programs

Conceptual PhysicsReading and Study Workbook N Chapter 28 239 Exercises 28.1 The Color Spectrum ... 244 Conceptual Physics Reading and Study Workbook NChapter 28 56.

FOREWORD. Physical fitness is inherent to mission readiness both domestically . and abroad. CF personnel may not always have access to a fitness facility or equipment while deployed or on travel-related duty. Bodyweight exercises do not require free weights or resistance training equipment. This training manual provides an easy-to-follow,

college Computer-Aided-Engineering and Design (CAED) lab, composed of twenty-five Unix-based workstations. Although the specific purposes of MECH407 lectures were to teach basic manufac-turing processes, the laboratory exercises focused on the computer aided design and analysis of parts, as in MECH302. As a result, students were

Somerset Wing Chun Kung Fu Risk Assessment ... Appropriate warm-up exercises must be conducted at the beginning of each session and a cool-down session at the end. The Instructor must control the number of students in the training area at any one time. Students must read the appropriate Policies and Club rules maintained on the organisation website www.somersetwingchun.com, a copy of which ...

This Vocabulary Power workbook gives you the practice you need to expand your vocabulary and improve your ability to understand what you read. Each lesson focuses on a single vocabulary concept or on a theme that ties together the list of words in the Word Bank. You then have several opportunities to learn the words by completing exercises on definitions, context clues, and word parts. You can ...

Wing Chun does not pit strength against strength but rather employs its unique understanding of angles and sensitivity to force to overcome aggression (fitness, age & sex are of no consequence). Many of the exercises are scientific in approach, and the systematic training methods can be carried out in a friendly atmosphere of co-operation as opposed to one of aggressive competition. This ...

of third grade Negro children might be more comprehensible to other members of. that group than the usual instructional materials. A random sample of third graders. was asked to. tell. stories. in response to four pictures. The stories were tape. recorded and then transcribed. Cloze exercises were made from passages in the

New Headway Intermediate Tests orkbook with further onsolidation exercises and writing tasks, a traditional methods of language teaching and more recent communicative approaches. Headstart , along with Headway taught and explained thoroughly, and all four language skills are developed systematically. The Headway series combines

2. 12-week workout system 3. Videos of the workout system exercises 4. The Venus Community: This is a private online community, exclusive for Venus Factor members only. You can meet and learn from other Venus members, start your own personal blog within the community, or just browse other members' blogs and forums for information. Your level of ...

threats; and business and service continuity management. The book builds upon the basics of risk assessment and writing an emergency plan, and then covers inter-agency working, command and control, communication, personal impact and business continuity as well as training, exercises and post-incident follow up.

101 More Drama Games and Activities This sequel to the best-selling 101 Drama Games and Activities contains inspirational and engaging games and exercises suitable for children, young people and adults. The activities can be used in drama lessons and workshops or during rehearsal and devising periods.

Topical Sermons 5 5BX Spiritual Fitness Plan INTRODUCTION 1. In the late 1950s, there was an exercise program called 5BX (Five Basic Exercises)... a. Developed for the Royal Canadian Air Force b. Published as a booklet with 23 million copies sold in Canada c. Consisted of five exercises to be done daily in 11 minutes 2. In this lesson, I would ...

IMPROVE YOUR VISION NATURALLY THROUGH A HEALTHIER DIET, LIFESTYLE AND VISION EXERCISES VISION EXERCISES & VISION EXERCISE AND RELAXATION ROUTINES PUBLISHERS NOTE: Every effort has been made to ensure that the information contained in this ebook is complete and accurate. However, neither the publisher nor the

environments for the beginning programmer to use. All of the examples in this text have been tested using BlueJ. Sample solutions for most exercises are available on the website for this text. 1.1 Java, the beginning James Gosling is referred to as the father of the Java programming lan-guage. He graduated with a BSc (1977) from the University ...

PI System Architecture, Planning and Implementation Course Page 10 1. PI System Basics 1.1 Course structure The course consists of instructor lead training with individual and group activities, coupled with student exercises. You will need to be familiar with your own corporate network topology, and

duction to Python programming. Because knowledge is cumulative, the early chapters pro-vide the conceptual basis for understanding programming and guide students through simple examples and exercises; subsequent chapters progressively present Python programming in detail, culminating with the development of comprehensive applications.

Exercise 5-6a Model a sphere with a dia-meter of 60mm. Exercise 5-6b Make an assembly using the sphere from exercise 5-6a three times. The sphe-res should all sit in a row and touch each other. Exercise 5-6c Make an assembly using the sphere from exercise 5-6a four times. The sphe-res should all sit in a row and touch each other.