## Practice Exercises for Expressions

Solve each of the practice exercises below. Each problem includes three CodeSkulptor links: one for a template that you should use as a starting point for your solution, one to our solution to the exercise, and one to a tool that automatically checks your solution.

1. There are 5280 feet in a mile. Write a Python statement that calculates and prints the number of feet in 13 miles.Miles to feet template --- Miles to feet solution --- Miles to feet (Checker)
2. Write a Python statement that calculates and prints the number of seconds in 7 hours, 21 minutes and 37seconds.Hours to seconds template --- Hours to seconds solution --- Hours to seconds (Checker)
3. The perimeter of a rectangle is 2w+2h, where w and h are the lengths of its sides. Write a Python statement that calculates and prints the length in inches of the perimeter of a rectangle with sides of length 4 and 7 inches.Perimeter of rectangle template ---Perimeter of rectangle solution --- Perimeter of rectangle (Checker)
4. The area of a rectangle is wh, where w and h are the lengths of its sides. Note that the multiplication operation is not shown explicitly in this formula. This is standard practice in mathematics, but not in programming. Write a Python statement that calculates and prints the area in square inches of a rectangle with sides of length 4 and 7 inches.Area of rectangle template Area of rectangle solution Area of rectangle (Checker)
5. The circumference of a circle is 2πr where r is the radius of the circle. Write a Python statement that calculates and prints the circumference in inches of a circle whose radius is 8 inches. Assume that the constant π=3.14.Circumference of circle template --- Circumference of circle solution --- Circumference of circle (Checker)
6. The area of a circle is πr2 where r is the radius of the circle. (The raised 2 in the formula is an exponent.) Write a Python statement that calculates and prints the area in square inches of a circle whose radius is 8 inches. Assume that the constant π=3.14. Area of circle template --- Area of circle solution --- Area of circle (Checker)
7. Given p dollars, the future value of this money when compounded yearly at a rate of r percent interest for y years is p(1+0.01r)y. Write a Python statement that calculates and prints the value of 1000 dollars compounded at 7percent interest for 10 years. Future value template --- Future value solution --- Future value (Checker)
8. Write a single Python statement that combines the three strings "My name is", "Joe" and "Warren" (plus a couple of other small strings) into one larger string "My name is Joe Warren." and prints the result. Name tag template --- Name tag solution --- Name tag (Checker)
9. Write a Python expression that combines the string "Joe Warren is 52 years old." from the string "Joe Warren" and the number 52 and then prints the result (Hint: Use the function str to convert the number into a string.) Name and age template --- Name and age solution --- Name and age (Checker)
10. The distance between two points (x0,y0) and (x1,y1) is (x0x1)2+(y0y1)2−−−−−−−−−−−−−−−−−−√. Write a Python statement that calculates and prints the distance between the points (2,2) and (5,6). Point distance template --- Point distance solution --- Point distance (Checker)

J'enseigne au
Lycée Paul SERUSIER
Avenue de Waldkappel
29270 CARHAIX PLOUGUER
Tél : 02 98 99 29 29
Site : www.lycee-serusier.fr

### footer2

Richard GAUTHIER
Professeur de Physique Appliquée
Certification ISN
Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser.

www.carhaix2020.bzh