CS代考 MANM491; 15 Credits PYTHON PROGRAMMING IN FINTECH

UNIVERSITY OF SURREY©
Faculty of Arts and Social Sciences
Surrey Business School
Postgraduate Programmes in Accounting & Finance

Copyright By PowCoder代写 加微信 powcoder

Module MANM491; 15 Credits PYTHON PROGRAMMING IN FINTECH
FHEQ Level M Examination
Problem set 2
Time allowed: 24 hours Autumn Assessment Period: 2021/22
Instructions to Candidates:
• This paper comprises of NINE Questions
• Answer all of them
• Each Question carries different marks that are notified after each question.
• Please make sure your codes can run properly in PyCharm
©Please note that this exam paper is copyright of the University of Surrey and may not be reproduced, republished or redistributed without written permission

Question 1
sum_number=0
while number<3: if number ==2: sum_number+=number print("The sum is", sum_number) Check whether there is a problem for this code? Explain why there is a problem? Question 2 After you revise the code, please run this code in the PyCharm. Explain why the output is 2. You can list each value change to justify your answer. [10 marks] Question 3 Create a program that asks the user for a login and password but only have three attempts. [10 marks] • Have PASSWORD variables defined in your program • Use input() to receive the password entered by the user • If login and password match the values of your LOGIN and PASSWORD variables, display "Access Granted", else, "Forbidden” • Users only have three attempts. More than three attempts, display “Account locked” sum_number=0 while number<3: if number ==2: sum_number+=number print("The sum is", sum_number) Question 4 In the class break and continue example, is it possible to write the code without Continue? If possible, how to write the code? [10 marks] while True: print('Who are you?') name = input() if name != 'Joe': print('Hello, Joe. What is the password? (It is a fish.)') password = input() if password == 'swordfish': print('Access granted.') Question 5 Use for and while loop to solve the following questions. • Display each letter in Python in each single line separately, but do not display letter “o”. The output likes: • Define a variable that has a value of 10. In the loop, each time the value of variable reduces one and print the variable value in a single line separately, but do not display when the variable value is 5. The output likes: Question 6 Please run this following code and explain the output. What do you learn from this example? def m(number, list_of_numbers): number = 1001 list_of_numbers[0] = 5555 def main(): x=1 y = [1, 2, 3] print("x is ", str(x)) print("y[0] is", str(y[0])) [10 marks] Question 7 Write a program that prints the following conversion table (note that 1 mile is 1.609 kilometres). [20 marks] You may explore online how to print a fixed space between two string variables. Question 8 Write a program that prints all the leap years in the twenty-first century (from 2001 to 2100), ten per line. Years should be separated by exactly one space. Hints: you may construct this in the loop structure. Hints: you may construct this in the loop structure. You may use a variable to count the number of leap year. [15 marks] Question 9 • In the class, we discussed to use “list” this function to do the real copy. Could you think other ways to do the real copy? Like using list comprehension and use copy function. • Alex is testing the following code. He is struggling with the output he got and he thought the output should be “Access Granted”. Could you please explain to him why his output is this. PASSWORD = "123" password = int(input("please enter your password: ")) if password == PASSWORD: print("Access Granted") print("Forbidden") Total: 100 Marks -END OF PAPER- Internal Examiner: Dr Shuhui Moderator: Dr Hanxiong Zhang 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com