Introduction to Programming in Python: Lab Exercises, Exams of Advanced Education

A series of programming exercises designed to introduce fundamental concepts in python programming. The exercises cover various topics, including time conversion, geometric calculations, and basic input/output operations. Each exercise provides a clear problem statement and instructions, allowing students to practice their coding skills and gain practical experience in python.

Typology: Exams

2024/2025

Available from 03/11/2025

alex-david-34
alex-david-34 🇿🇦

4.5

(4)

5.6K documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
D335-INTRODUCTION TO PROGRAMMING IN PYTHON
22.1 Lab: Convert to Seconds
Write a program that reads in hours, minutes, and seconds as input, and outputs the time in seconds
only.
22.2 Lab: Convert from Seconds
People find it easier to read time in hours, minutes, and seconds rather than just seconds.
Write a program that reads in seconds as input and outputs the time in hours, minutes, and seconds.
22.3 Lab: Pizza Party
Given the number of people attending a pizza party, output the number of needed pizzas and total cost.
For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs
$14.95.
22.4 Lab: Hypotenuse
Given two numbers that represent the lengths of a right triangle's legs (sides adjacent to the right
angle), output the length of the third side (i.e. hypotenuse) with two digits after the decimal point.
pf3

Partial preview of the text

Download Introduction to Programming in Python: Lab Exercises and more Exams Advanced Education in PDF only on Docsity!

D335-INTRODUCTION TO PROGRAMMING IN PYTHON

22.1 Lab: Convert to Seconds Write a program that reads in hours, minutes, and seconds as input, and outputs the time in seconds only. 22.2 Lab: Convert from Seconds People find it easier to read time in hours, minutes, and seconds rather than just seconds. Write a program that reads in seconds as input and outputs the time in hours, minutes, and seconds. 22.3 Lab: Pizza Party Given the number of people attending a pizza party, output the number of needed pizzas and total cost. For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs $14.95. 22.4 Lab: Hypotenuse Given two numbers that represent the lengths of a right triangle's legs (sides adjacent to the right angle), output the length of the third side (i.e. hypotenuse) with two digits after the decimal point.

22.5 Lab: Area of a Triangle Using Heron's formula, you can calculate the area of a triangle if you know the lengths of all three sides. Given the length of each side of a triangle as input, calculate the area of the triangle using Heron's formula as follows: s = half of the triangle's perimeter area = the square root of s(s-a)(s-b)(s-c), where a, b, and c are each sides of the triangle. 22.6 Ordering Pizza A local pizza shop is selling a large pizza for $9.99. Given the number of pizzas to order as input, output the subtotal for the pizzas, and then output the total after applying a sales tax of 6% 22.7 LAB: Square root Given a floating-point number as input, output the square root of the given number. 22.8 LAB: Volume and area of cylinder The volume and area of a cylinder are calculated as: Volume = πr2h Area = 2πrh + 2πr