﻿# 1. Evaluate. (1 mark) (5 ** 2) // 3 # 2. Identify syntax errors and make corrections. (5 marks) # a) def function2a(n) answer = n print(Answer) # b) def function2b(): pw = input (Enter password:) if (pw = "password"): print("Access Granted") elif: print("Access Denied") # 3. Determine the printed output. (5 marks) # a) def function3a(x): result = 3*x print(result) » function3a(5) » function3a("hi") # b) def function3b(n): a = 8 b = 6 if (n < -5): a = a + n elif (n > 5): b = b + a a = b + n print(a) » function3b(10) » function3b(-10) » function3b(0) # 4. Explain the difference. (4 marks) # a) ... between print and return. # b) ... between '1.0' and 1.0. # 5. Write a function called convertLB() that asks the user to enter a mass in kg, # converts the mass into lb, and prints the result on the screen. The function also # needs to handle exceptions properly. (5 marks) # # Hint: The formula for the conversion is massLB = 2.2 * massKG. # # » convertLB() # standard case # Enter mass in kg: 10 # Mass in lb: 22 # » convertLB() # exceptional case (negative mass) # Enter mass in kg: -10 # Invalid mass # » convertLB() # exceptional case (string mass) # Enter mass in kg: ten # Invalid mass # # Evaluation Rubric: # 5 = Fully solved, few syntax errors # 4 = Mostly solved, few syntax errors # 3 = Solved, many syntax errors. # 2 = Not solved, but logical attempt is made. # 1 = Not solved, but some attempt is made. # 0 = Nothing is produced. #