LabSheet 1 Answers PDF

Title LabSheet 1 Answers
Author Arturas Kudriavcevas
Course Introduction to Computing
Institution Coventry University
Pages 2
File Size 50 KB
File Type PDF
Total Downloads 108
Total Views 136

Summary

LabSheet 1 Answers...


Description

121COM: Introduction to Computing Academic Year 2016/17

Week 1 Answers

Worksheet Exercises Q1 Binary Operators: (a) 2 (b) 73 (c) x = 1020304 and y = 5 Q2 Operator Order: (a) 0.0005165289256198347 (one pair) (b) 12.56 (none) (c) 2.0 (two pairs) (d) 150.0 (none) Q3 Variable Assignment: 1.85 meters Q4 Getting input from a user: Enter a name and see if it works! Q5 Type conversion: If user enters 2008 it should print 49 dog years. If they enter 1997 then 126 dog years.

Lab Exercises 1 Q1 If you enter 1.8 for metres and 90 for kilograms the BMI should be 27.777777777777775. Q2 If you left the money in the bank you would have 11,040.81 after 5 years. Product A would give 11,359.07 and Product B 11,446.64. So Product B is the best option. Q3 The bus takes 29.6 minutes and cycling takes 25.14 minutes.

1

121COM: Introduction to Computing

Week 1 Answers

Lab Exercises 2 Script1.py 1 syntax error Script2.py 1 syntax error and 1 runtime error Script3.py 1 syntax error and 1 logic error (wrong variable used) Script4.py 1 syntax error and 1 logic error (can only get multiples of 11 at cheaper price). Script5.py 1 syntax error and 2 logic errors (missing quotes and missing capital letter). Script6.py 1 syntax error and 1 runtime error. Also, the whole thing is logically wrong as it weights the latest grade as high as all past ones! Script7.py 1 logic, but when fixed introduced 1 runtime for further fix (type conversions). Script8.py 2 logic errors (missing brackets). Script9.py 3 logic errors (plus very poorly formatted code). The Total price should be 69.0. Of this 22.73 is fuel and The three logic errors were:

46.27 is tax.

1. the VAT was charged on the fuel cost only and not the Hydrocarbon Duty; 2. everything was calculated in pence but the print statement said pounds; 3. the final answer was not rounded to nearest pence. Also, the code was messy and hard to read making the errors harder to find. It is better to: store intermediate values; keep the calculation and the displaying of the answer separate; only round at the end.

Extended Task The actual answers will vary with the daily exchange rate. I suggest copying the question into Google and comparing the answers your code gives with what Google says!

2...


Similar Free PDFs