- a= bool([])
- b= bool(())
- c= bool(range(0))
- d= bool({})
- e= bool(set())

Which of the above variables represent True ?

Options are :

- None of the variables represents True (Correct)
- a ,b, c, d
- All Variables represent True
- c

Answer :None of the variables represents True

Options are :

- 8/3*4 (Correct)
- 8%3*4
- 8-3*4
- 8//3*4

Answer :8/3*4

- s='Python is easy'
- s1=s[-7:]
- s2=s[-4:]
- print(s1+s2)

What is the result?

Options are :

- iseasyeasy
- easyeasy
- is easy easy
- s easyeasy
- is easyeasy (Correct)

Answer :is easyeasy

- numbers=[10,20,30,40]
- x=0

In which of the following cases 10 will be printed to the console?

Options are :

- for i in (30,40,50): if i not in numbers: x=x+10 print(x) (Correct)
- for i in (30,40,50): if i not in numbers: x=x+5 print(x)
- for i in (30,40,50): if i in numbers: x=x+5 print(x) (Correct)
- for i in (30,40,50): if i in numbers: x=x+10 print(x)

Answer :for i in (30,40,50): if i not in numbers: x=x+10 print(x) for i in (30,40,50): if i in numbers: x=x+5 print(x)

a=3b=5a += 2**3a -=b//2//3print(a)

What is the result?

Options are :

- 12
- 13
- 11 (Correct)
- 10

Answer :11

- start=input('How old were you at the time of joining?')
- end=input('How old are you today?')

Which of the following code is valid to print Congratulations message?

Options are :

- print('Congratulations on '+ str(end-start)+' Years of Service!')
- print('Congratulations on '+ (int(end)-int(start))+' Years of Service!')
- print('Congratulations on '+ int(end-start)+' Years of Service!')
- print('Congratulations on '+ str(int(end)-int(start))+' Years of Service!') (Correct)

Answer :print('Congratulations on '+ str(int(end)-int(start))+' Years of Service!')

- a=bool(0)
- b=bool(3)
- c=bool(0.5)
- d=bool(0.0)

Which variables represent True?

Options are :

- d, a
- All Variables
- a,b
- c,d
- b,c (Correct)

Answer :b,c

`a=eval(input('Enter a number for the expression:'))`

Which of the following is a valid expression for the given requirement?

Options are :

- b = -(a)**2
- b = (a-)**2
- b = (a)**-2
- b = (-a)**2 (Correct)

Answer :b = (-a)**2

Options are :

- None of the above (Correct)
- employees[0:501]
- employees[1:1000]
- employees[-10:10]

Answer :None of the above

- age=0
- minor=False
- name='test'

The types of age, minor and name variables, respectively:

Options are :

- int, bool, char
- float, bool, str
- int, bool, str (Correct)
- bool, bool, str

Answer :int, bool, str

- numbers=[10,20,30,40,50]
- alphabets=['a','b','c','d','e']
- print( numbers is alphabets)
- print( numbers == alphabets)
- numbers=alphabets
- print( numbers is alphabets)
- print( numbers == alphabets)

What is the result?

Options are :

- True False True False
- False False True True (Correct)
- False True True True
- False True False True

Answer :False False True True

a=21b=6print(a/b)print(a//b)print(a%b)

What is the result?

Options are :

- 3 3 3
- 3.5 3 3 (Correct)
- 3.5 3.5 3
- 3.0 3 3

Answer :3.5 3 3

- a=1
- b=2
- c=4
- d=6

Which of the following expression results in -4?

Options are :

- (b+c)//a%d
- (a+b)//c*d
- (a+b)//c%d
- (a+b)//d-c (Correct)

Answer :(a+b)//d-c

Options are :

- 11/3
- 23%5 (Correct)
- 13//4 (Correct)
- 3**1 (Correct)

Answer :23%5 13//4 3**1

- subjects=['java','python','sap']
- more_subjects=['java','python','sap']
- extra_subjects=more_subjects

In which cases, True will be printed to the console?

Options are :

- print(subjects == extra_subjects) (Correct)
- print(subjects is extra_subjects)
- print(extra_subjects is more_subjects) (Correct)
- print(subjects is more_subjects)

Answer :print(subjects == extra_subjects) print(extra_subjects is more_subjects)

- Boy
- Cat
- Dog

Options are :

- l=['Apple','Boy','Cat','Dog'] for x in l: if len(x) == 3: print(x) (Correct)
- l=['Apple','Boy','Cat','Dog'] for x in l: print(x)
- l=['Apple','Boy','Cat','Dog'] l1=l[1:] for x in l1: print(x) (Correct)
- l=['Apple','Boy','Cat','Dog'] for x in l: if len(x) != 3: print(x)

Answer :l=['Apple','Boy','Cat','Dog'] for x in l: if len(x) == 3: print(x) l=['Apple','Boy','Cat','Dog'] l1=l[1:] for x in l1: print(x)

Options are :

- employees[-3:]
- employees[497:500]
- employees[497:]
- All the above (Correct)

Answer :All the above

- x='ACROTE'
- y='APPLE'
- z='TOMATO'

Which of the following won't print 'CAT' to the console

Options are :

- print(x[1]+y[0]+z[0])
- print(x[-5]+y[0]+z[0])
- print(x[-5]+y[0]+z[-2])
- print(x[2]+y[1]+z[1]) (Correct)

Answer :print(x[2]+y[1]+z[1])

`result=(2*(3+4)**2-(3**3)*3)`

What is result value?

Options are :

- 16
- 18
- 19
- 17 (Correct)

Answer :17

- sum=count=done=0
- average=0.0
- while(done != -1):
- rating=float(input('Enter Next Rating(1-5),-1 for done'))
- if rating == -1:
- break
- sum+=rating
- count+=1
- average=float(sum/count)
- #Line-1

Which of the following print() statement should be placed at Line-1 to meet requirement?

Options are :

- print('The average star rating for the new coffee is:{:.2f}'.format(average)) (Correct)
- print('The average star rating for the new coffee is:{:.2d}'.format(average))
- print('The average star rating for the new coffee is:{:2f}'.format(average))
- print('The average star rating for the new coffee is:{:2.2d}'.format(average))

Answer :print('The average star rating for the new coffee is:{:.2f}'.format(average))

- 1. print('V:{:.2f}'.format(123.45678)) will print to the console V:123.46
- 2. print('V:{:.2f}'.format(123.4)) will print to the console V:123.40
- 3. print('V:{:8.2f}'.format(1.45678)) will print to the console V: 1.46
- 4. print('V:{:08.2f}'.format(1.45678)) will print to the console V:00001.46

Which of the above statements are True?

Options are :

- only 1 and 2
- only 1 and 3
- only 2 and 4
- 1,2,3 and 4 (Correct)

Answer :1,2,3 and 4

- name=input('Enter Your Name:')
- score=0
- count=0
- sum=0
- while(score != -1):
- score=int(input('Enter your scores: (-1 to end)'))
- if score==-1:
- break
- sum+=score
- count+=1
- average_score=sum/count
- #Line-1

Which print statement we have to take at Line-1 to meet requirements.

Options are :

- print('%-20s,Your average score is: %4.1f' %(name,average_score)) (Correct)
- print('%-20f,Your average score is: %4.1f' %(name,average_score))
- print('%-20s,Your average score is: %1.4f' %(name,average_score))
- print('%-20s,Your average score is: %4.1s' %(name,average_score))

Answer :print('%-20s,Your average score is: %4.1f' %(name,average_score))

- numbers=[0,1,2,3,4,5,6,7,8,9]
- index=0
- while (index<10)#Line-1
- print(numbers[index])
- if numbers(index) = 6#Line-2
- break
- else:
- index += 1

To print 0 to 6,which changes we have to perform in the above code?

Options are :

- Line-1 should be replaced with while(index<10): (Correct)
- Line-2 should be replaced with if numbers[index]==6: (Correct)
- Line-2 should be replaced with if numbers[index]=6:
- Line-1 should be replaced with while(index>0):

Answer :Line-1 should be replaced with while(index<10): Line-2 should be replaced with if numbers[index]==6:

- employee_number=input('Enter Your Employee Number(dd-ddd-dddd):')
- parts=employee_number.split('-')
- valid=False
- if len(parts) == 3:
- if len(parts[0])==2 and len(parts[1])==3 and len(parts[2])==4:
- if parts[0].isdigit() and parts[1].isdigit() and parts[2].isdigit():
- valid=True
- print(valid)

Which of the following is True about this code

Options are :

- It will throw an error because of the misuse of split() method
- It will throw an error because of the misuse of isDigit() method
- There is no error, but it won't fulfill our requirements.
- No changes are required for this code, and it can fulfill the requirement. (Correct)

Answer :No changes are required for this code, and it can fulfill the requirement.

- You are writing a function to compute roots
- The function must meet the following requirements
- If a is non-negative, return a**(1/b)
- If a is negative and even, return "Result is an imaginary number"
- if a is negative and odd,return -(-a)**(1/b)

Which of the following root function should be used?

Options are :

- def root(a,b): if a>=0: answer=a**(1/b) elif a%2 == 0: answer="Result is an imaginary number" else: answer=-(-a)**(1/b) return answer (Correct)
- def root(a,b): if a>=0: answer=a**(1/b) elif a%2 != 0: answer="Result is an imaginary number" else: answer=-(-a)**(1/b) return answer
- def root(a,b): if a>=0: answer=a**(1/b) if a%2 == 0: answer="Result is an imaginary number" else: answer=-(-a)**(1/b) return answer
- def root(a,b): if a>=0: answer=a**(1/b) elif a%2 == 0: answer=-(-a)**(1/b) else: answer="Result is an imaginary number" return answer

Answer :def root(a,b): if a>=0: answer=a**(1/b) elif a%2 == 0: answer="Result is an imaginary number" else: answer=-(-a)**(1/b) return answer

Options are :

- import math.sqrt as sq
- import sqrt from math as sq
- from math import sqrt as sq (Correct)
- from math.sqrt as sq

Answer :from math import sqrt as sq

- import math
- l =[str(round(math.pi)) for i in range (1, 6)]
- print(l)

What is the result?

Options are :

- ['3', '3', '3', '3', '3'] (Correct)
- ['3', '3', '3', '3', '3','3']
- ['1', '2', '3', '4', '5']
- ['1', '2', '3', '4', '5','6']

Answer :['3', '3', '3', '3', '3']

Options are :

- random.randint(5,12)
- random.randint(5,11) (Correct)
- random.randrange(5,12,1) (Correct)
- random.randrange(5,11,1)

Answer :random.randint(5,11) random.randrange(5,12,1)

- import random
- fruits=['Apple','Mango','Orange','Lemon']

Which of the following will print some random value from the list?

Options are :

- print(random.sample(fruits))
- print(random.sample(fruits,3)[0]) (Correct)
- print(random.choice(fruits)) (Correct)
- print(random.choice(fruits)[0])

Answer :print(random.sample(fruits,3)[0]) print(random.choice(fruits))

Options are :

- import random randints=[random.randint(1,7) for i in range(1,8)] (Correct)
- import random randints=[random.randint(1,8) for i in range(1,8)]
- import random randints=random.randrange(1,7)
- import random randints=random.randint(1,7)

Answer :import random randints=[random.randint(1,7) for i in range(1,8)]

- import random
- fruits=['Apple','Mango','Orange','Lemon']
- random_list=[random.choice(fruits)[:2] for i in range(3)]
- print(''.join(random_list))

Which of the following are possible outputs?

Options are :

- ApApAp (Correct)
- ApMaOr (Correct)
- LeMaOr (Correct)
- OrOraM

Answer :ApApAp ApMaOr LeMaOr

- Microsoft Python Certification Exam (98-381) Practice Tests Set 3
- Microsoft Python Certification Exam (98-381) Practice Tests Set 4
- Microsoft Python Certification Exam (98-381) Practice Tests Set 5
- Microsoft Python Certification Exam (98-381) Practice Tests Set 6
- Python Generators
- Python Decorators
- Python Logging
- Pythons Finally Block