Python Final Exam

Ace your homework & exams now with Quizwiz!

2. What is the type of the following variable: True?

Bool

16. What is the output of the following lines of code:x="Go"if(x!="Go"):print('Stop')else:print('Go ')print('Mike')

Go Mike

17. What is the output of the following lines of code:x="Go"if(x=="Go"):print('Go ')else:print('Stop') print('Mike'):

Go Mike

11. What is the result of the following operation '1,2,3,4'.split(','):

['1','2','3','4']

9. Consider the tuple A=((11,12),[21,22]), that contains a tuple and list. What is the result of the following operation A[1]:

[21,22]

13. How do you cast the list 'A' to the set 'a'?

a=set(A)

25. Consider the following line of code: with open(example1,"r") as file1: What mode is the file object in?

read

22. Consider the class Points, what are the data attributes:class Points(object):def __init__(self,x,y):self.x=xself.y=ydef print_point(self):print('x=',self.x,'y=',self.y):

self.x self.y

8. Consider the tuple tuple1=("A","B","C" ), what is the result of the following operationtuple1[-1]?

"C"

21. Consider the function add, what is the result of calling the following Add('1','1') (look closely at the return statement )def Add(x,y):z=y+xreturn(y):

'1'

20. What is the output of the following few lines of code ?A=['1','2','3']for a in A:print(2*a):

'11' '22' '33'

6. The variables A='1' and B='2' ,what is the result of the operation A+B?

'12'

4. Consider the string A='1234567', what is the result of the following operation: A[1::2]

'246'

18. how many iterations are performed in the following loop?for n in range(3):print(n):

3

3. What is the result of the following operation int(3.2)?

3

5. Consider the string Name="Michael Jackson" , what is the result of the following operation Name.find('el')

5

1. Certificate #1 Python for Data Science 1.What is the result of the following operation 3+2*2?

7

12. Concatenate the following lists A=[1,'a'] and B=[2,1,'d']:

A+B

23. What is the result of running the following lines of code ?class Points(object):def __init__(self,x,y):self.x=xself.y=ydef print_point(self):print('x=',self.x,' y=',self.y)p1=Points(1,2)p1.print_point():

x=1 y=2

24. What is the result of running the following lines of code ?class Points(object):def __init__(self,x,y):self.x=xself.y=ydef print_point(self):print('x=',self.x,' y=',self.y)p2=Points(1,2)p2.x=2p2.print_point():

x=2 y=2

14. Consider the Set: V={'A','B'}, what is the result of V.add('C')?

{'A','B','C'}

15. Consider the Set: V={'A','B','C' }, what is the result of V.add('C')?

{'A','B','C'}

19. What does the following loop print?for n in range(3):print(n+1):

1 2 3

10. Consider the tuple A=((11,12),[21,22]), that contains a tuple and list. What is the result of the following operation A[0][1]:

12

7. Consider the variable F="You are wrong", Convert the values in the variable F to uppercase?

F.upper()


Related study sets

CNC2 Ch 38: Assessment of Digestive and Gastrointestinal Function

View Set

History Unit 1 Assessment Questions

View Set

CCS Exam Prep Health Data Content and Standards

View Set

2019 Ninja PRITE Question Book (Part 1)

View Set