python代写 python作业代写 python程序代写 代写python程序

python exam代写 python test代写

                                                                                                                         

234128 – Introduction To Computing With Python

                                       

Winter Semester 2019-2020

                                       

Final Exam A – 2020-02-26 Course staff : Israel Gutter – Lecturer and Tutor –

                                       

israel.gutter@gtiit.edu.cn

                                       

Exam Details : Time duration : 180 minutes

                                       

It’s allowed to use Python software during the exam.

                                       

NO OTHER HELP MATERIAL OF ANY KIND IS ALLOWED.

                                       

SPECIFICALLY THE FOLLOWING ARE NOT ALLOWED :

                                       

Any written or printed material, slides, notebook, books etc – all these are NOT allowed.

                                       

Also, Internet is NOT ALLOWED, nor any other kind of electronic data. Only Python software is allowed.

                                       

COMMUNICATION OF ANY SORT WITH ANY OTHER PERSON DURING THE EXAM IS TOTALLY FORBIDDEN.

                                       

Notice : Appendix A that is attached to this questionnaire describes all Python control structures, operators and built in functions that are allowed to be used in the exam. No other things are allowed.
Please notice that specific requirements in every question may override the appendix list.

                                       

1
All Rights Reserved ©

                                                                                                                                                  

               

                                                                                                                                                  

Exam Procedure :
See Appendix B that is attached in the end of this questionnaire.

                                       

Exam Structure :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                       

Question

                                                                                                                                               
                                                                                                                                                                       

Points

                                                                                                                                                                                                
                                                                                                                                                                       

Answer will be written in the file

                                                                                                                                               
                                                                                                                                                                       

1

                                                                                                                                               
                                                                                                                                                                       

30

                                                                                                                                               
                                                                                                                                                                       

_q1.txt

                                                                                                                                               
                                                                                                                                                                       

2

                                                                                                                                               
                                                                                                                                                                       

25

                                                                                                                                                                                                
                                                                                                                                                                       

_q2.txt

                                                                                                                                               
                                                                                                                                                                       

3

                                                                                                                                               
                                                                                                                                                                       

25

                                                                                                                                               
                                                                                                                                                                       

q3.txt

                                                                                                                                               
                                                                                                                                                                       

4

                                                                                                                                               
                                                                                                                                                                       

20

                                                                                                                                               
                                                                                                                                                                       

                                                                                                                                               

                                                                                                                                                                       

Total

                                                                                                                                               
                                                                                                                                                                                                                         

100

                                                                                                                                               
                                       
                                                                                               

2
All Rights Reserved ©

                                                                       

               

                                                                                                                                                  

Exam Submission :

                                       

You need to submit 5 files : all the four files as written in the above table in which you’ve written your answers to the exam questions. Also do you need to submit the file _declaration.pdf (or jpg etc) in which your signature (hand writing ONLY) appears.

                                       

All 5 files have been sent to you in Email. DO NOT CHANGE THEIR NAMES. DO NOT CHANGE WHAT IS ALREADY WRITTEN IN THE FILES.

                                       

Submission will be done in Moodle in the Exam A Section. Each file will be submitted in a SEPARATE entry.

                                       

Good Luck !

                                                                                                                                                                                                         

3
All Rights Reserved ©

                                                                       

               

                                                                                                                         

Question 1 ( 30 points ) :

                                       

Write your answers for all parts of this question in the file _q1.txt that you’ve got by Email. DO NOT CHANGE WHAT IS ALREADY WRITTEN THERE. DO NOT CHANGE THE NAME OF THE FILE. JUST ADD YOUR ANSWERS IN THE APPROPRIATE PLACES.

                                       

PartA(4points):

                                       

What is the output of the following code ? Explain SHORTLY. (Points may be reduced for correct answer without explanation).

                                       

a=sum([x for x in range(5,15,5) if x%10==5]) print(a)

                                       

Part B ( 6 points ) :

                                       

What is the output of the following code ?

                                       

def f(n):
return [[int(j>=i) for j in range(n)] for i in range(n)]

                                                                                                                                                                                                         

def show(mat): n=len(mat)
for i in range(n):

                                       

for j in range(n): print(mat[i][j],end=' ')

                                       

print('') show(f(5))

                                                                                                                                                       

4
All Rights Reserved ©

                                                                       

               

                                                                                                                         

PartC(6points):

                                       

The function f(my_list) gets a list my_list and returns a new list in which each element is duplicated twice.

                                       

Example :
f([-1,4,5]) == [-1,-1,4,4,5,5]
f([7]) == [7,7]
Complete the following code for the function f :

                                       

def f(my_list):
return __________________________________________________

                                       

Requirements :
All the code to be completed MUST be written in 1 line after the word return.
Must not use recursion.
Remark : Solution that does not fulfil the requirements is not guarantee to get points.

                                       

Part D ( 6 points ) :

                                       

The function f(s,ch) gets a string s and a character ch. Then it returns a string that is similar to s but does NOT have the character ch. If ch does not appear in s then the result string is equal to s.

                                       

Example : f('abacadaeafaga','a')=='bcdefg' f('abacadaeafaga','A')=='abacadaeafaga'

                                       

5
All Rights Reserved ©

                                                                                                                         

               

                                                                                                                         

Complete the following code for the function f :

                                       

def f(s, ch):
return __________________________________________________

                                       

Requirements :

                                       
  1.                                                 
  2.                                                         

    You must NOT use any loop, nor comprehensions, nor recursion.

                                                    
  3.                                                
  4.                                                         

    Remember that string in Python is immutable and can not be changed.

                                                    
  5.                                                
  6.                                                         

    You must NOT define any function of your own.

                                                    
  7.                                         
                                       

Hint : use operations that we have learned about strings.

                                       

PartE(8points): Subpart E1 (4 points) :

                                       

Given the following code, complete it in the signed place with any necessary definitions/code so that when running it we get the output

                                       

True

                                       

# -------------------------------------------------------------------------------- # Complete HERE any definitions/code, in 1 or more lines print(d['one']+d['two'] == d['+'](d['one'],d['two']) == 3)
# --------------------------------------------------------------------------------

                                       

6
All Rights Reserved ©

                                                                                                

               

                                                                                                                         

Subpart E2 (4 points) :

                                       

Given the following code, complete it in the signed place with any necessary definitions/code so that when running it we get the output

                                       

True
(Notice that the code here is like in subpart E1, just we have here ‘3’ instead of 3.

                                       

# -------------------------------------------------------------------------------- # Complete HERE any definitions/code, in 1 or more lines print(d['one']+d['two'] == d['+'](d['one'],d['two']) == '3')
# --------------------------------------------------------------------------------

                                       

Question 2 ( 25 points ) :

                                       

Write your answers for all parts of this question in the file _q2.txt that you’ve got by Email. DO NOT CHANGE WHAT IS ALREADY WRITTEN THERE. DO NOT CHANGE THE NAME OF THE FILE. JUST ADD YOUR ANSWERS IN THE APPROPRIATE PLACES.

                                       

Let my_list be a list of positive integer numbers. All elements are greater than 0.

                                       

We say that my_list is parity sorted if all elements that are even are sorted left to right, small to big. Also all elements that are odd are sorted left to right, small to big.

                                       

We say that a parity sorted list is almost balanced if the list can not have more than 2 successive elements (one after the other) with the same parity (either all even or all odd).

                                       

7
All Rights Reserved ©

                                                                                                                         

               

                                                                                                                         

Example :

                                       

Even elements (left to right) are 12 , 14 , 14 , 16 , 22 , 32 , 62

                                       

Odd elements (left to right) are 3 , 9 , 11 , 21 , 31 , 31 , 49 , 51

                                       

We can see : all even elements are sorted left to right, small to big. Also all odd numbers are such. In addition no more than 2 successive elements (one after the other) of the same parity.

                                       

If a list does not have even elements then we can think as all even elements are sorted. Also the same for the odd elements.
Specifically, an empty list or 1 element list is parity sorted, and also almost balanced.

                                       

Part A (10 points) :

                                       

Write a function get_max(my_list)

                                       

The function gets a parity sorted list, my_list, which is also almost balanced, as a parameter. my_list is not empty.

                                       

The function returns the max value in my_list.
Requirement : The function should be efficient in time and space. In addition to the code, write in the answer notebook :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                       

12

                                                                                                                                               
                                                                                                                                                                       

3

                                                                                                                                               
                                                                                                                                                                       

9

                                                                                                                                               
                                                                                                                                                                       

14

                                                                                                                                               
                                                                                                                                                                       

14

                                                                                                                                               
                                                                                                                                                                       

11

                                                                                                                                               
                                                                                                                                                                       

21

                                                                                                                                               
                                                                                                                                                                       

16

                                                                                                                                               
                                                                                                                                                                       

31

                                                                                                                                               
                                                                                                                                                                       

22

                                                                                                                                               
                                                                                                                                                                       

31

                                                                                                                                               
                                                                                                                            &nbs
京ICP备2025144562号-1
微信
程序代写,编程代写
使用微信扫一扫关注
在线客服
欢迎在线资讯
联系时间: 全天