- 797 step-by-step solutions
- Solved by professors & experts
- iOS, Android, & web

- Question : E1 - The ?rst exercise concerns some very basic mathematics and programming: assign the result of 1C1 to a variable and print the value of that variable. Filename: 1plus1.
- Question : E2 - 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.
- Question : E3 - 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.
- Question : E4 - 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.
- Question : E5 - The density of a substance is de?ned as % D 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.
- Question : E6 - Exercise 1.6: Compute the growth of money in a bank Let p be a bank
- Question : E7 - Suppose somebody has written a simple one-line program for computing sin.1/: x=1; print
- Question : E8 - Type the following program in your editor and execute it. If your program does not work, check that you have copied the code correctly.
- Question : E9 - 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/ C cos2.x/ D 1? from math import sin, cos x = pi/4 1_val = math.sin^2(x) + math.cos^2(x) print 1_VAL b) Compute s in meters when s D v0t C 21at2, with v0 D 3 m/s, t D 1 s, a D 2 m/s2.
- Question : E10 - The bell-shaped Gaussian function, f.x/ D 1 p 2? s exp??12 ?x ?s m?2?; (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 D 0, s D 2, and x D 1. Verify the program
- Question : E11 - The drag force, due to air resistance, on an object can be expressed as Fd D 1 2 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 coef?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 D mg, where g D 9:81 m 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 % D 1:2 kg m?3. We have A D ?a2 for any ball with radius a. For a football, a D 11 cm and the mass is 0.43 kg. The drag coef?cient CD varies with the velocity and can be taken as 0.4. 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 D kg m=s2). Also print the ratio of the drag force and the gravity force. De?ne CD, %, A, V , m, g,
- Question : E12 - Exercise 1.12: How to cook the perfect egg As an egg cooks, the proteins ?rst denature and then coagulate. When the temper- ature 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 70 ?C. 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): t D M2=3c?1=3 K?2.4?=3/2=3 ln?0:76To ? Tw Ty ? Tw ? : (1.9) 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 D 47 g for a small egg and M D 67 g for a large egg, ? D 1:038 g cm?3, c D 3:7 J g?1 K?1, and K D 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 D 100 ?C and Ty D 70 ?C, and compute t for a large egg taken from the fridge (To D 4 ?C) and from room temperature (To D 20 ?C).
- Question : E13 - 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
- Question : E14 - 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 each case. 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 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 Filename: find_errors_division.
- Question : E15 - Figure out why the following program does not work: C = A + B A = 3 B = 2 print C Filename: find_errors_vars.
- Question : E16 - Try the following statements in an interactive Python shell. Explain why some statements fail and correct the errors. 1a = 2 a1 = b x = 2 y = X + 4 # is it 6? from Math import tan print tan(pi) pi = "3.14159
- Question : E17 - Find errors in the coding of a formula Given a quadratic equation, ax2 C bx C c D 0; the two roots are x1D ? b C p b2 ? 4ac 2a ; x2 D ? b ? p b2 ? 4ac 2a : (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.
- Question : E18 - Find errors in a program What is the problem in the following program? from math import pi, tan tan = tan(pi/4) tan2 = tan(pi/3) print tan, tan2 Filename: find_errors_tan.

## Customer reviews

No reviews.