Week 3 Exercise
.pdf
keyboard_arrow_up
School
University of Wollongong *
*We aren’t endorsed by this school
Course
110
Subject
Mathematics
Date
May 18, 2024
Type
Pages
2
Uploaded by DukeTarsier4247
SCIT, University of Wollongong CSIT110/CSIT810 Autumn Session 2019 Lab Exercise (Week 3: Mon 18 March - Friday 22 March) (this is not an assignment) Objectives
●
Able to use print function for output ●
Able to use variables ●
Able to use string concatenation ●
Able to translate number into string ●
Able to use escape sequences ●
Able to use string format Given the following code: product_code = "377B" product_name = "Beef Liquid Stock" product_size = "250mL" product_price = 2.15 1) What is the output of the following statement? print("product_code + product_name + product_size") Write the python code, run it, and check your answer. 2) What is the output of the following statement? print(product_code + " product_name " + product_size) Write the python code, run it, and check your answer. 3) What is the output of the following statement? print(product_code + ", " + product_name + ", + product_size") Write the python code, run it, and check your answer. Page 1 of 2
4) What is the output of the following statement? print(product_code + ", " + product_name + ", " + product_size) Write the python code, run it, and check your answer. 5) Write one print statement using the above variables and string addition so that it produces the
following exact output: 377B: Beef Liquid Stock, 250mL
6) Write one print statement using the above variables and string addition so that it produces the
following exact output: "Beef Liquid Stock", 250mL
7) Write one print statement using the above variables and string addition so that it produces the
following exact output: Beef Liquid Stock, 250mL, $2.15
8) Write one print statement using the above variables and string format so that it produces the
following exact output: 377B: Beef Liquid Stock, 250mL
9) Write one print statement using the above variables and string format so that it produces the
following exact output: "Beef Liquid Stock", 250mL
10) Write one print statement using the above variables and string format so that it produces the
following exact output: Beef Liquid Stock, 250mL, $2.15
END OF THE LAB EXERCISE Page 2 of 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help