Student Number: (enter on the line below) Student Name: (enter on the line below) HS1031 INTRODUCTION TO PROGRAMMING FINAL ASSESSMENT TRIMESTER 1, 2021 Assessment Weight: 40 total marks Instructions: • All questions must be answered by using the answer boxes provided in this paper. • Completed answers must be submitted to Blackboard by the published due date and time. Submission instructions are at the end of this paper. Purpose: This assessment consists of six (6) questions and is designed to assess your level of knowledge of the key topics covered in this unit Question 1 ( 6 marks) Multiple Choice Questions Please write the letter of the correct answer in the third column of the table below (i.e. a, b, c, or d). Question Answer 1 2 3 4 5 6 Total 1. Which of the following lists of operators is ordered by increasing precedence? a. +, *, ** b. *, /, % c. **, *, + d. %,/,* 2. When the function range receives three arguments, what does the third argument specify? a. the last value of a sequence of integers b. the last value of a sequence of integers plus 1 c. the last value of a sequence of integers minus 1 d. the increment amount of the sequence, be default plus 1 3. Consider the following code: How many time this program will run? a. At least Once b. Twice c. It depends d. Infinitely 4. In a recursive function call, where does Python store the values of function’s arguments: a. String b. Dictionary c. Stack frame d. List 5. After importing the math module, what function can be used to display its resources in Python IDLE? a. show(math) b. dir(math) c. print(math) d. display(math) 6. Consider the following expression: -%3d- % num, which of the following statements is correct? a. num must be a float number b. num must be an integer c. num must be a string d. It does not matter Question 2 (6 marks) Case Study Sandeep is a nascent Python developer. He has been asked by his manager to use functions in his code whenever possible. However, Sandeep feels that using functions is a waste of time. Provide three reasons to convince Sandeep to start using functions in his scripts. ANSWER: ** Answer box will enlarge as you type Question 3 (6 marks) For each of the following code snippets, explain: (i) what does the code do? And (ii) What is the expected output? (1) (2) ANSWER: (1) (2) Question 4 (6 marks) Consider the following code snippet. Answer the following questions: (a) What do you think the purpose of this program is? (b) What does the statement in Line 4 do? (c) What does the code in Line 12 achieve? (d) What happens if the print statement in Line 16 is moved a tab forward (i.e. aligned with the if-else statement in lines 12 & 14)? ANSWER: (a) (b) (c) (d) Question 5 (8 marks) Countries The attached text file (countries.txt) includes a list of countries in a non-specific order. Furthermore, many of these countries are repeated in the file. You were asked by your company to produce a list of world’s. Write a Python code to retrieve data from the file and print out the unique names of countries a descending order. Your program should prompt the users to determine whether the list should be printed in ascending or descending order. Save your file as countries.py (make sure to include it in your submission). ANSWER: Python script Question 6 (8 marks) Python language provides various built-in functions which can be used by programs without worrying about the code. One of the most frequently used built-in functions in Python is the range function. Answer the following questions: (a) Explain what does the range function do. (b) The range function has three arguments: start, stop and step. Describe the function of each of these arguments. (c) Develop a function (name it uRange(start,stop,step)) which imitates Python’s range function. uRange take at least one argument (stop) and maximum of three. • If only one argument is passed to uRange, it is assumed to be the ‘stop’. Start takes zero, while step is equated to one. • If two arguments are passed to uRange, those would be ‘start’ and ‘stop’. Start takes zero, while step is equated to one. Step is equal to one by default. • If three arguments are passed to uRange, those would be ‘start’, ‘stop’ and ‘step’. Use None as a default value for the second and third parameters. So the first part of the function definition determines what the parameters are, whilst the rest of the code uses the values of these parameters to generate a sequence of numbers counting up or down (in the form of list). See below examples for the output: ANSWER: (a) (b) (c) Python script END OF FINAL ASSESSMENT Submission instructions: • Save your answers in the the answer boxes provided in this paper, including your Python code. Save your file with your STUDENT ID NUMBER and UNIT CODE e.g. EMV54897 HS1031 • This file must be saved in MICROSOFT WORD FORMAT ONLY • For answers that involves Python script, make sure to also save your code in .py file format. • Place ALL your submission files (MS Word + Python files) in one folder (again, with your STUDENT ID NUMBER and UNIT CODE e.g. EMV54897 HS1031), and convert the folder into a ZIP file (RAR format is NOT acceptable) • Upload your submission to the appropriate link on Blackboard • Only one submission is accepted. Please ensure your submission is the correct document (this would be your ZIP file). • All submissions are automatically passed through SafeAssign to assess academic integrity.


Student Number: (enter on the line below)
Student Name: (enter on the line below)

HS1031
INTRODUCTION TO PROGRAMMING
FINAL ASSESSMENT
TRIMESTER 1, 2021
Assessment Weight: 40 total marks
Instructions:
• All questions must be answered by using the answer boxes provided in this paper.
• Completed answers must be submitted to Blackboard by the published due date and time.
Submission instructions are at the end of this paper.
Purpose:
This assessment consists of six (6) questions and is designed to assess your level of knowledge of the key topics covered in this unit

Question 1 ( 6 marks)
Multiple Choice Questions
Please write the letter of the correct answer in the third column of the table below (i.e. a, b, c, or d).
Question Answer
1
2
3
4
5
6
Total
1. Which of the following lists of operators is ordered by increasing precedence?
a. +, *, **
b. *, /, %
c. **, *, +
d. %,/,*
2. When the function range receives three arguments, what does the third argument specify?
a. the last value of a sequence of integers
b. the last value of a sequence of integers plus 1
c. the last value of a sequence of integers minus 1
d. the increment amount of the sequence, be default plus 1
3. Consider the following code:

How many time this program will run?
a. At least Once
b. Twice
c. It depends
d. Infinitely
4. In a recursive function call, where does Python store the values of function’s arguments:
a. String
b. Dictionary
c. Stack frame
d. List
5. After importing the math module, what function can be used to display its resources in Python IDLE?
a. show(math)
b. dir(math)
c. print(math)
d. display(math)
6. Consider the following expression: -%3d- % num, which of the following statements is correct?
a. num must be a float number
b. num must be an integer
c. num must be a string
d. It does not matter
Question 2 (6 marks)
Case Study
Sandeep is a nascent Python developer. He has been asked by his manager to use functions in his code whenever possible. However, Sandeep feels that using functions is a waste of time. Provide three reasons to convince Sandeep to start using functions in his scripts.
ANSWER: ** Answer box will enlarge as you type
Question 3 (6 marks)
For each of the following code snippets, explain: (i) what does the code do? And (ii) What is the expected output?
(1)

(2)

ANSWER:
(1)
(2)
Question 4 (6 marks)
Consider the following code snippet.

Answer the following questions:
(a) What do you think the purpose of this program is?
(b) What does the statement in Line 4 do?
(c) What does the code in Line 12 achieve?
(d) What happens if the print statement in Line 16 is moved a tab forward (i.e. aligned with the if-else statement in lines 12 & 14)?
ANSWER:
(a)
(b)
(c)
(d)
Question 5 (8 marks)
Countries
The attached text file (countries.txt) includes a list of countries in a non-specific order. Furthermore, many of these countries are repeated in the file. You were asked by your company to produce a list of world’s.
Write a Python code to retrieve data from the file and print out the unique names of countries a descending order. Your program should prompt the users to determine whether the list should be printed in ascending or descending order. Save your file as countries.py (make sure to include it in your submission).
ANSWER:
Python script
Question 6 (8 marks)
Python language provides various built-in functions which can be used by programs without worrying about the code. One of the most frequently used built-in functions in Python is the range function.
Answer the following questions:
(a) Explain what does the range function do.
(b) The range function has three arguments: start, stop and step. Describe the function of each of these arguments.
(c) Develop a function (name it uRange(start,stop,step)) which imitates Python’s range function. uRange take at least one argument (stop) and maximum of three.
• If only one argument is passed to uRange, it is assumed to be the ‘stop’. Start takes zero, while step is equated to one.
• If two arguments are passed to uRange, those would be ‘start’ and ‘stop’. Start takes zero, while step is equated to one. Step is equal to one by default.
• If three arguments are passed to uRange, those would be ‘start’, ‘stop’ and ‘step’.
Use None as a default value for the second and third parameters. So the first part of the function definition determines what the parameters are, whilst the rest of the code uses the values of these parameters to generate a sequence of numbers counting up or down (in the form of list).
See below examples for the output:

ANSWER:
(a)
(b)
(c) Python script

END OF FINAL ASSESSMENT
Submission instructions:
• Save your answers in the the answer boxes provided in this paper, including your Python code. Save your file with your STUDENT ID NUMBER and UNIT CODE e.g. EMV54897 HS1031
• This file must be saved in MICROSOFT WORD FORMAT ONLY
• For answers that involves Python script, make sure to also save your code in .py file format.
• Place ALL your submission files (MS Word + Python files) in one folder (again, with your STUDENT ID NUMBER and UNIT CODE e.g. EMV54897 HS1031), and convert the folder into a ZIP file (RAR format is NOT acceptable)
• Upload your submission to the appropriate link on Blackboard
• Only one submission is accepted. Please ensure your submission is the correct document (this would be your ZIP file).
• All submissions are automatically passed through SafeAssign to assess academic integrity.

Private and Confidential

Yours all information is private and confidential; it is not shared with any other party. So, no one will know that you have taken help for your Academic paper from us.



This essay is written by:

Prof. Amanda Verified writer

Finished papers: 435

Proficient in:

English, History, Business and Entrepreneurship, Nursing, Psychology, Management

You can get writing help to write an essay on these topics
100% plagiarism-free

Hire This Writer
© 2017 theacademicessays. All Rights Reserved. Design & Developed by theacademicessays.

Ask Your Homework Today!

We have over 1000 academic writers ready and waiting to help you achieve academic success

CLICK HERE TO GET ORIGINAL ANSWERS FROM WRITERS

WhatsApp
Hello! Need help with your assignments?
Loading...