Python Final Exam

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

15. What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x=int(input)) y=int(input)) x=x/y y=y/x print(y)

1

29. What is the output of the following snippet? 1st=[3,1,-2] print(1st[1st[-1]])

1

8. Left-sided binding determines that the result of the following expression: 1//2*3

0

14. What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively?

8.0

57. What is the output of the following snippet? def fun(x,y,z): return x+2*y+3*z print(fun(0,z=1,y=3))

9

21. An operator able to check whether two values are equal is coded as:

==

23. How namy stars will the following snippet send to the console? i=0 while i<=3 i+=2 print("*")

two

59. What is the output of the following snippet? dct = { 'one':'two', 'three':'one','two':'three'} v= dct['one'] for k in range(len(dct)): v= dct[v] print(v)

two

50. The following snippet: def func1(a): return a**a def func2(a) return func1(a)*func1(a) print(func2(2))

will output 16

11. What is the output of the following snippet? x=1 y=2 z=x x=y print(x,y)

21

54. What is the output of the following snippet? def any(): print(var+1, end=") var=1 any() print(var)

21

16. What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x=input() y=int(input()) print(x*y)

33333

33. After execution of the following snippet, the sum of all vals elements will equal to: vals=[0,1,2,] vals=insert(0,1) del vals[1]

4

47. What is the output of the following snippet? def fun(x) x+=1 return x x=2 x=fun(x+1) print(x)

4

53. What is the outputof the following snippet? def fun(x): global y y=x*x return y fun(2) print(y)

4

58. What is the output of the following snippet? def fun(inp=2,out=3): return inp * out print(fun(out=2))

4

20. What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x=int(input() y=int(input()) print(x+y)

6

39. What is the output of the following snippet? T = [[3-i for i in range (3)] for j in range (3)] s = 0 for i in range(3): s+= T[i][i] print(s)

6

45. What is the output of the following snippet? def f(x): if x==0: return 0 return x + f(x-1) print(f(3))

6

1. The \n diagraph forces the print() function to:

break the outputline

43. a built-in function is a function which:

comes with Python, and is an integral part of Python

28. How many hashes will the following snippet send to the console? var=1 while var<10 print("#") var=var<<1

four

4. The 0o prefix means that the number after it is denoted as:

octal

25. How many stars will the following snippet send to the console? i=0 while i<=5: i+=1 if i%2==0: break print("*")

one

7. Only one of the following statements is false - which one?

the result of the / operator is always an integer value

56. What is the output of the following snippet? list=['Mary', 'had', 'a', 'little', 'lamb'] def list(1st): del 1st[3] 1st [3] = 'ram' print(list(list))

the snippet is erroneous

40. What is the output of the following snippet? 1st = [[0,1,2,3] for i in range (2)] print(1st [2][0])

the snippet will cause a runtime error

18. What is the output of the following snippet? x=2+2*5 print(x)

the snippet will cause an execution error

44. The fact that tuples belong to sequence types means:

they can be indexed and sliced like lists

27. How many hashes will the following snippet send to the console? var=0 while var<6 var+=1 if var%2==0: continue print("#")

three

38. How many elements does the L list contain? 1st = [i for i in range(-1,2)]

three

12. What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x=input() y=input() print(x+y)

-24

17. What is the output of the following snippet? z=y=x=1 print(x,y,z,sep='*')

1*1*1

19. What ins the output of the following snippet? x=1/2+3//3+4**2

17.5

26. How many hashes will the following snippet send to the console? for i in range(1) print("#") else: print("#")

2

31. What is the output of the following snippet? a=1 b=0 c=a&b d=a|b e=a^b print(c+d+e)

2

60. What is the output of the following snippet? tup = (1,2,4,8) tup = tup[1:-1] tup = tup[0] print(tup)

2

3. The value twenty point twelve times ten raised to the power of eight should be written as:

20.12E84

51. Which of the following statements is false?

The None value may not be used outside functions

22. The value eventually assigned to x is equal to:

True

30. What value will be assigned to the x variable? z=10 y=0 x=y<z and z>y or y>z and z<y

True

9. One of the following variables names is illegal - which one?

True

37. What is the output of the following snippet? 1st =[1,2,3] for v in range(len(1st1)): 1st,insert(1,1st[v]) print(|1)

[1,1,1,1,2,3]

24. What is the output of the following snippet? 1st=[1,2,3,4] print(-3:-2])

[2]

36. What is the output of the following snippet? 1st1 = [1,2,3] 1st2 =[] for v in 1st1: 1st2.insert(0,v) print(12)

[3,2,1]

10. The print() function can output values of:

any number of arguments (including zeros)

41. Which of the following lines properly starts a parameterless function definition?

def fun():

46. Which of the following lines properly starts a function using two parameters, both with zeroed defaulted values?

def fun(a=0,b=0):

6. The result of the following division: 1/1

is equal to 1.0

49. The following snippet: def func(a,b): return a**a print(func(2))

is erronous

55. Assuming that tuple is a correctly created tuple, the fact that tuples are immutable means that the following instruction: tuple[1]=tuple[1]+tuple[0]

is illegal

42. A function defined in the following way: def function(x=0): return x

may be invoked without any argument or with just one

34. Take a look at the snippet, and choose gthe true statement: nums = [1,2,3,] vals = nums del vals[1:2]

nums and vals are of the same length

35. Which of the following sentences is true? nums = [1,2,3,] vals = nums[-1:-2]

nums is longer than vals

5. The ** operator:

performs exponentiaton

48. What code would you insert into the commented line to obtain the output that reads: a b c Code: dct={} 1st=['a','b','c','d',] for i in range(len(1st)-1): dct[1st[i]] = 1st[i],) for i in sorted(dct,keys()): k=dct[i] # insert your code

print(k[0])

32. The second assignment: vals=[0,1,2] vals=[0], vals[2], vals[0]

reverses the list

2. The meaning of the keyword parameter is determined by:

the arguments's name specified along with its value

13. What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x=int(input)) y=int(input)) x=x//y y=y//x print(y)

the code will cause a runtime error

52. What is the output of the following snippet? def fun(x): of x%2==o: return 1 else: return print(fun(fun(2))+1)

the code will cause a runtime error


Kaugnay na mga set ng pag-aaral

Nurs 204 - Chapter 15: Head and Neck (3)

View Set

Chap. 7 Organization, Teamwork, and Communication

View Set

The Art of Public Speaking, Ch. 11-14, 16-19

View Set

Leadership Exam 2: Ch 8- Power and Influence

View Set

CYSE 300- Introduction to Cybersecurity

View Set