CSCI101_Lab07_Algorithms I
CSCI101_Lab07_Algorithms I
4. For each part below, what is the value of C after the code executes,
(a) (b)
B = 60; C=15 B = 60; C=15
if B >= 20: if B >= 20:
C=9 C=9
elif C < 10: if C < 10:
C=11 C=11
Page 1
University of Science and Technology
Communications & Information Engineering Program
CSCI 101: Introduction to Computer Science
Algorithms I
Page 2
University of Science and Technology
Communications & Information Engineering Program
CSCI 101: Introduction to Computer Science
Algorithms I
Example:
class 1 grades: 4 1 2 421
class 1 students: ahmed mohamed yasser
class 2 grades: 7 10 8
class 2 students: samaa ehab roaa
Page 3
University of Science and Technology
Communications & Information Engineering Program
CSCI 101: Introduction to Computer Science
Algorithms I
12. A grocery store launched its delivery service from 8 AM to 9 PM. Number of items
changes everyday and is updated by the stock clerks.
a) Take from the stock clerk the available number in each department and the new
prices.
b) You can take orders from customers till the end of all items or end of working
hours and print for each the total they should pay.
Page 4
University of Science and Technology
Communications & Information Engineering Program
CSCI 101: Introduction to Computer Science
Algorithms I
c) make a promo code with 30% discount ‘123456’ as anyone tells it takes this
discount but only on Milk
d) make a report for the grocery manager showing ratios of sold products from
each department to know what they should buy more next time.
ratio = (number of sold items from a department)/total number of sold items
e) print the ratios in the report in an ascending order.
Example:
Page 5
University of Science and Technology
Communications & Information Engineering Program
CSCI 101: Introduction to Computer Science
Algorithms I
We sold today:
20.00 % Meat
20.00 % Seafood
20.00 % Milk
20.00 % Bread
20.00 % Oil
Page 6