Questions
ayuda
option
My Daypo

ERASED TEST, YOU MAY BE INTERESTED ONpython basic 4

COMMENTS STATISTICS RECORDS
TAKE THE TEST
Title of test:
python basic 4

Description:
python basic set 4

Author:
AVATAR
Smart tech junior
(Other tests from this author)


Creation Date:
25/04/2021

Category:
Others

Number of questions: 23
Share the Test:
Facebook
Twitter
Whatsapp
Share the Test:
Facebook
Twitter
Whatsapp
Last comments
No comments about this test.
Content:
You work for a company that distributes media for all ages.You are writing a function that assigns a rating based on a user's age.The function must meet the following requirements.Anyone 18 years old or older receives a rating of "A"Anyone 13 or older,but younger than 18, receives a rating of "T"Anyone 12 years old or younger receives a rating of "C"If the age is unknown ,the rating is set to "C"Which of the following code meets above requirements: 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 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" 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.
Consider the following Python Code: 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? 1 2 3 4.
Consider the code: startmsg = "hello" endmsg = "" for i in range(0,len(startmsg)): endmsg = startmsg[i] + endmsg print(endmsg) What is the result? olleh hello IndexError hlelo.
Consider the code: 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? [13, 40, 17, 10] [50, 40, 10] [13,4,17,10] [50,40,17,10].
You want to add comments to your code so that other team members can understand it. What should you do? Place the comments after the #sign on any line 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.
We are creating a function to calculate the power of a number by using python. We have to ensure that the function is documented with comments. Consider the code(Line numbers included for reference): 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? Lines 01 through 04 will be ignored for syntax checking The hash sign(#) is optional for lines 01 and 03. The String in line 06 will be interpreted as a commen.
You are writing a python script to convert student marks into a grade. The grades are defined as follows: 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? Line-1 should be replaced with if marks <= 90: Line-1 should be replaced with if marks <= 90: Line-3 should be replaced with if marks>=70 and marks <= 80 : No Changes are required. (Correct).
You are developing a Python application for an online product distribution company. You need the program to iterate through a list of products and escape when a target product ID is found. Which of the following code can fulfill our requirement productIdList=[0,1,2,3,4,5,6,7,8,9] index=0 while index productIdList=[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=[1,2,3,4,5,6,7,8,9] index=1 while index.
You are writing a python program that displays all prime numbers from 2 to 200. Which of the following is the proper code to fulfill our requirement? 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 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).
You created the following program to locate a conference room and display room name. 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? Invalid Syntax Mismatched data type(s) Misnamed variable(s) None of these.
The XYZ Book Company needs a way to determine the cost that a student will pay for renting a Book. The Cost is dependent on the time of the Book is returned. However, there are also special rates on Saturday and Sundays. The Fee Structure is shown in the following list: The cost is $3.00 per night. If the book is returned after 9 PM, the student will be charged an extra day. If the Book is rented on a Sunday, the student will get 50% off for as long as they keep the book. If the Book is rented on a Saturday, the student will get 30% off for as long as they keep the book. We need to write the code to meet these requirements. # 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? The Cost of Book Rental is:$ 7.0 The Cost of Book Rental is:$ 8.0 The Cost of Book Rental is:$ 9.0 The Cost of Book Rental is:$ 10.0.
We are developing one school automation application. If the student marks between 80 and 100, then we have to offer 'A' grade. Which code block we have to use? if marks>=80 and marks>=100: grade='A' if marks>=80 or marks<=100: grade='A' if 80<=marks<=100: grade='A' if marks>80: grade='A'.
Consider the code import random print(random.sample(range(10), 7)) Which of the following is valid? 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 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.
Consider the following python code: weight=62.4 zip='80098' value=+23E4 The types of weight, zip, and value variables, respectively: float, str, str int, str, float double, str, float float, str, float.
Consider the code: 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? print('Congratulations on '+ (int(end)-int(start))+' Years of Service!') print('Congratulations on '+ str(int(end)-int(start))+' Years of Service!') print('Congratulations on '+ int(end-start)+' Years of Service!') print('Congratulations on '+ str(end-start)+' Years of Service!').
You are developing a python application for your company.A list named employees contains 600 employee names,the last 3 being company management.You need to slice employees to display all employees excluding management.Which two code segments we should use? there are two options select any one...? employees[1:-2] employees[:-3] employees[1:-3] employees[0:-2] employees[0:-3].
You are interning for XYZ Cars Company. You have to create a function that calculates the average velocity of the vehicle on a 2640 foot(1/2 mile)track. 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. yyy should be replaced with float and yyy should be replaced with float 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.
You develop a Python application for your company. You required to accept input from the user and print that information to the user screen. Consider the code: print('Enter Your FullName:') #Line-1 print(fullname) At Line-1, which code we have to write? fullname=input input('fullname') input(fullname) fullname=input().
The XYZ Company has hired you as an intern on the coding team that creates an e-commerce application. You must write a script that asks the user for a value. The value must be used as a whole number in a calculation, even if the user enters a decimal value. Which of the following meets this requirement? 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?'))) .
The XYZ organics company needs a simple program that their call center will use to enter survey data for a new coffee variety. The program must accept input and return the average rating based on a five-star scale. The output must be rounded to two decimal places. Consider the code: 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? print('The average star rating for the new coffee is:{:.2f}'.format(average)) 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)).
We are developing a sports application. Our program should allow players to enter their name and score. The program will print player name and his average score. Output must meet the following requirements:The user name must be left aligned. If the user name is fewer than 20 characters ,additional space must be added to the right. The average score must be 3 places to the left of the decimal point and one place to the right of the decimal point ( like YYY.Y). Consider the code: 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)) print('%-20s,Your average score is: %4.1f' %(name,average_score)) 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)).
You are writing a Python program to validate employee numbers. The employee number must have the format dd-ddd-dddd and consists of only numbers and dashes. The program must print True if the format is correct, otherwise print False. 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 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.
You are coding a math utility by using python. You are writing a function to compute rootsThe function must meet the following requirements If r is non-negative, return r**(1/s) If r is negative and even, return "Result is an imaginary number" if r is negative and odd, return -(-r)**(1/s)Which of the following root function should be used? 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) 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.
Report abuse Consent Terms of use