0% found this document useful (0 votes)
347 views

Python Exercises

A Python program is needed to summarize book order information from a shop. The program should return a list of 2-tuples with the order number and total price of each order, adding €10 to orders under €100. It should do this for two different lists - one with the order data in sublists, and one with the data structured as [ordernumber, (article, quantity, price), ...] using lambda and map functions. The second part of the problem asks for a similar program to calculate order totals, this time using a different input list structure of [ordernumber, (article, quantity, price), ...] for each order.

Uploaded by

harini
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
347 views

Python Exercises

A Python program is needed to summarize book order information from a shop. The program should return a list of 2-tuples with the order number and total price of each order, adding €10 to orders under €100. It should do this for two different lists - one with the order data in sublists, and one with the data structured as [ordernumber, (article, quantity, price), ...] using lambda and map functions. The second part of the problem asks for a similar program to calculate order totals, this time using a different input list structure of [ordernumber, (article, quantity, price), ...] for each order.

Uploaded by

harini
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1. Imagine an accounting routine used in a book shop.

It works on a list with sub lists,


which look like this:

Order Price per


Book Title and Author Quantity
Number Item
34587 Learning Python, Mark Lutz 4 40.95
98762 Programming Python, Mark Lutz 5 56.80
77226 Head First Python, Paul Barry 3 32.95
Einführung in Python3, Bernd
88112 3 24.99
Klein

Write a Python program, which returns a list with 2-tuples. Each tuple consists of a
the order number and the product of the price per items and the quantity. The product
should be increased by 10,- € if the value of the order is smaller than 100,00 €. Write
a Python program using lambda and map.

2. The same bookshop, but this time we work on a different list. The sublists of our lists
look like this: [ordernumber, (article number, quantity, price per unit), ... (article
number, quantity, price per unit) ] Write a program which returns a list of two tuples
with (order number, total amount of order).

You might also like