Options are :

- def get_rating(age): if age>=18: rating="A" elif age>=13: rating="T" else: rating="C" return rating (Correct)
- def get_rating(age): if age>=18: rating="A" if age>=13: rating="T" else: rating="C" return rating
- def get_rating(age): if age>18: rating="A" elif age>13: rating="T" else: rating="C" return rating
- def get_rating(age): if age>=18: rating="A" elif age>=13: rating="T" else: rating="C" pass rating

Answer :def get_rating(age): if age>=18: rating="A" elif age>=13: rating="T" else: rating="C" return rating

- def count_letter(letter,word_list):
- count=0
- for word in word_list:
- if letter in word:
- count +=1
- return count
- word_list=['apple','pears','orange','mango']
- letter=input('Enter some alphabet symbol:')
- letter_count=count_letter(letter,word_list)
- print(letter_count)

If the user provides input 'a' then what is the result?

Options are :

- 1
- 2
- 3
- 4 (Correct)

Answer :4

- startmsg = "hello"
- endmsg = ""
- for i in range(0,len(startmsg)):
- endmsg = startmsg[i] + endmsg
- print(endmsg)

What is the result?

Options are :

- olleh (Correct)
- hello
- IndexError
- hlelo

Answer :olleh

- x = [13,4,17,10]
- w = x[1:]
- u = x[1:]
- y = x
- u[0] = 50
- y[1] = 40
- print(x)

What is the result?

Options are :

- [13, 40, 17, 10] (Correct)
- [50, 40, 10]
- [13,4,17,10]
- [50,40,17,10]

Answer :[13, 40, 17, 10]

Options are :

- Place the comments after the #sign on any line (Correct)
- Place the comments after the last line of the code separated by a blank line
- Place the comments before the first line of code separated by a blank line
- Place the comments inside parentheses anywhere

Answer :Place the comments after the #sign on any line

- 01 # The calc_power function calculates exponents
- 02 # x is the base
- 03 # y is the exponent
- 04 # The value of x raided to the y power is returned
- 05 def calc_power(x, y):
- 06 comment="#Return the value"
- 07 return x**y #raise x to the power y

Which of the following statements are true?

Options are :

- Lines 01 through 04 will be ignored for syntax checking (Correct)
- The hash sign(#) is optional for lines 01 and 03.
- The String in line 06 will be interpreted as a comment

Answer :Lines 01 through 04 will be ignored for syntax checking

- 90 through 100 --> A grade
- 80 through 89 --> B grade
- 70 through 79 --> C grade
- 65 through 69 --> D grade
- 0 through 64 --> E grade

And the developed application is :

- # Grade Converter
- marks=int(input('Enter Student Marks:'))
- if marks >=90: #Line-1
- grade='A'
- elif marks>=80: #Line-2
- grade='B'
- elif marks>=70: #Line-3
- grade='C'
- elif marks>=65:
- grade='D'
- else:
- grade='E'
- print('Your grade is:',grade)

Which of the following changes should be performed to fulfill the requirement?

Options are :

- Line-1 should be replaced with if marks <= 90:
- Line-2 should be replaced with if marks>=80 and marks <= 90 :
- Line-3 should be replaced with if marks>=70 and marks <= 80 :
- No Changes are required. (Correct)

Answer :No Changes are required.

Options are :

- productIdList=[0,1,2,3,4,5,6,7,8,9] index=0 while index
- productIdList=[0,1,2,3,4,5,6,7,8,9] index=1 while index
- productIdList=[0,1,2,3,4,5,6,7,8,9] index=0 while index
- productIdList=[0,1,2,3,4,5,6,7,8,9] index=0 while index

Answer :productIdList=[0,1,2,3,4,5,6,7,8,9] index=0 while index

Options are :

- p=2 while p<=200: is_prime=True for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==True: print(p) p=p+1 (Correct)
- p=2 is_prime=True while p<=200: for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==True: print(p) p=p+1
- p=2 while p<=200: is_prime=True for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==False: print(p) p=p+1
- p=2 while p<=200: is_prime=True for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==True: print(p)

Answer :p=2 while p<=200: is_prime=True for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==True: print(p) p=p+1

- rooms={1:'Left Conference Room',2:'Right Conference Room'}
- room=input('Enter the room number:')
- if not room in rooms:#Line-3
- print('Room does not exist')
- else:
- print('The room name is:'+rooms[room])

team reported that the program sometimes produces incorrect results.You need to troubleshoot the program. Why does Line-3 Fails to find the rooms?

Options are :

- Invalid Syntax (Correct)
- Mismatched data type(s)
- Misnamed variable(s)
- None of these

Answer :Invalid Syntax

- # XYZ Book Rented Amount Calculator
- ontime=input('Was Book returned before 9 pm? y or n:').lower()
- days_rented=int(input('How many days was book rented?'))
- day_rented=input('What day the Book rented?').capitalize()
- cost_per_day=3.00
- if ontime == 'n':
- days_rented=days_rented+1
- if day_rented=='Sunday':
- total=(days_rented*cost_per_day)*0.5
- elif day_rented=='Saturday':
- total=(days_rented*cost_per_day)*0.7
- else:
- total=(days_rented*cost_per_day)
- print('The Cost of Book Rental is:$',total)

If the Book rented on 'Sunday,' the number of days Book rented is 5, and Book returned after 9 PM,, then what the result is?

Options are :

- The Cost of Book Rental is:$ 7.0
- The Cost of Book Rental is:$ 8.0
- The Cost of Book Rental is:$ 9.0 (Correct)
- The Cost of Book Rental is:$ 10.0

Answer :The Cost of Book Rental is:$ 9.0

Options are :

- if marks>=80 and marks>=100: grade='A'
- if marks>=80 or marks<=100: grade='A'
- if 80<=marks<=100: grade='A' (Correct)
- if marks>80: grade='A'

Answer :if 80<=marks<=100: grade='A'

- import random
- print(random.sample(range(10), 7))

Which of the following is valid?

Options are :

- It will print a list of 10 unique random numbers from 0 to 6
- It will print a list of 7 unique random numbers from 0 to 9 (Correct)
- It will print a list of 7 unique random numbers from 0 to 10
- It will print a list of 7 unique random numbers from 1 to 10

Answer :It will print a list of 7 unique random numbers from 0 to 9

- weight=62.4
- zip='80098'
- value=+23E4

The types of weight, zip, and value variables, respectively:

Options are :

- float, str, str
- int, str, float
- double, str, float
- float, str, float (Correct)

Answer :float, str, float

- 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 '+ (int(end)-int(start))+' Years of Service!')
- print('Congratulations on '+ str(int(end)-int(start))+' Years of Service!') (Correct)
- print('Congratulations on '+ int(end-start)+' Years of Service!')
- print('Congratulations on '+ str(end-start)+' Years of Service!')

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

Options are :

- employees[1:-2]
- employees[:-3] (Correct)
- employees[1:-3]
- employees[0:-2]
- employees[0:-3] (Correct)

Answer :employees[:-3] employees[0:-3]

- Consider the python code
- distance=yyy(input('Enter the distance travelled in feet:')) #Line-1
- distance_miles=distance/5280
- time=yyy(input('Enter the time elapsed in seconds:')) #Line-2
- time_hours=time/3600
- velocity=distance_miles/time_hours
- print('The average Velocity:',velocity,'miles/hour')

To generate the most precise output, which modifications should be done at Line-1 and at Line-2.

Options are :

- yyy should be replaced with float and yyy should be replaced with float (Correct)
- yyy should be replaced with float and yyy should be replaced with int
- yyy should be replaced with int and yyy should be replaced with float
- yyy should be replaced with int and yyy should be replaced with int

Answer :yyy should be replaced with float and yyy should be replaced with float

- print('Enter Your FullName:')
- #Line-1
- print(fullname)

At Line-1, which code we have to write?

Options are :

- fullname=input
- input('fullname')
- input(fullname)
- fullname=input() (Correct)

Answer :fullname=input()

Options are :

- items=input('How many items you required?')
- items=float(input('How many items you required?'))
- items=str(input('How many items you required?'))
- items=int(float(input('How many items you required?'))) (Correct)

Answer :items=int(float(input('How many items you required?')))

- 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 the 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))

- 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))

- n=[0,1,2,3,4,5,6,7,8,9]
- i=0
- while (i<10)#Line-1
- print(n[i])
- if n(i) = 6#Line-2
- break
- else:
- i += 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(i<10): (Correct)
- Line-2 should be replaced with if n[i]==6: (Correct)
- Line-2 should be replaced with if n[i]=6:
- Line-1 should be replaced with while(i>0):

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

- empno=input('Enter Your Employee Number(dd-ddd-dddd):')
- parts=empno.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.

Options are :

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

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

- 90 through 100 --> A grade
- 80 through 89 --> B grade
- 70 through 79 --> C grade
- 65 through 69 --> D grade
- 0 through 64 --> E grade

And developed application is :

- # Grade Converter
- marks=int(input('Enter Student Marks:'))
- if marks >=90: #Line-1
- grade='A'
- elif marks>=80: #Line-2
- grade='B'
- elif marks>=70: #Line-3
- grade='C'
- elif marks>=65:
- grade='D'
- else:
- grade='E'
- print('Your grade is:',grade)

Which of the following changes should be performed to fulfill the requirement?

Options are :

- Line-1 should be replaced with if marks <= 90:
- Line-2 should be replaced with if marks>=80 and marks <= 90 :
- Line-3 should be replaced with if marks>=70 and marks <= 80 :
- No Changes are required. (Correct)

Answer :No Changes are required.

Options are :

- products=[0,1,2,3,4,5,6,7,8,9] index=0 while index
- products=[0,1,2,3,4,5,6,7,8,9] index=1 while index
- products=[0,1,2,3,4,5,6,7,8,9] index=0 while index
- products=[0,1,2,3,4,5,6,7,8,9] index=0 while index

Answer :products=[0,1,2,3,4,5,6,7,8,9] index=0 while index

Options are :

- p=2 while p<=200: is_prime=True for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==True: print(p) p=p+1 (Correct)
- p=2 is_prime=True while p<=200: for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==True: print(p) p=p+1
- p=2 while p<=200: is_prime=True for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==False: print(p) p=p+1
- p=2 while p<=200: is_prime=True for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==True: print(p)

Answer :p=2 while p<=200: is_prime=True for i in range(2,p): if p % i == 0: is_prime=False break if is_prime==True: print(p) p=p+1

- Microsoft Python Certification Exam (98-381) Practice Tests Set 5
- Microsoft Python Certification Exam (98-381) Practice Tests Set 6
- How to print a blank line in python
- Python Introduction
- Microsoft Python Certification Exam (98-381) Practice Tests Set 2
- Microsoft Python Certification Exam (98-381) Practice Tests Set 1
- Python Generators
- Python Decorators