Questions
ayuda
option
My Daypo

ERASED TEST, YOU MAY BE INTERESTED ONpython basic 2

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

Description:
python basic

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


Creation Date:
19/04/2021

Category:
Others

Number of questions: 31
Share the Test:
Facebook
Twitter
Whatsapp
Share the Test:
Facebook
Twitter
Whatsapp
Last comments
No comments about this test.
Content:
Consider the following variable declarations: a= bool([]) b= bool(()) c= bool(range(0)) d= bool({}) e= bool(set()) Which of the above variables represent True ? None of the variables represents True a ,b, c, d All Variables represent True c.
Which of the following expression will generate max value? 8/3*4 8%3*4 8-3*4 8//3*4.
Consider the code: s='Python is easy' s1=s[-7:] s2=s[-4:] print(s1+s2) What is the result? iseasyeasy easyeasy is easy easy s easyeasy is easyeasy.
Consider the python code numbers=[10,20,30,40] x=0 In which of the following cases 10 will be printed to the console? There are two answers select any one...! for i in (30,40,50): if i not in numbers: x=x+10 print(x) 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) for i in (30,40,50): if i in numbers: x=x+10 print(x).
You have the following code: a=3 b=5 a += 2**3a -=b//2//3 print(a) What is the result? 12 13 11 10.
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 '+ 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!').
a=bool(0) b=bool(3) c=bool(0.5) d=bool(0.0) Which variables represent True? d, a All Variables a,b c,d b,c.
You are writing a python program that evaluates an arithmetic expression. The expression is described as b is equals a multiplied by negative one, then raised to the second power, where a is the value which will be input and b is the result. a=eval(input('Enter a number for the expression:')) Which of the following is a valid expression for the given requirement? b = -(a)**2 b = (a-)**2 b = (a)**-2 b = (-a)**2.
You are developing a python application for your company.A list named employees contains 500 employee names. In which cases we will get IndexError while accessing employee data? None of the above employees[0:501] employees[1:1000] employees[-10:10].
Consider the following python code: age=0 minor=False name='test' The types of age, minor and name variables, respectively: int, bool, char float, bool, str int, bool, str bool, bool, str.
Consider the lists: 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? True False True False False False True True False True True True False True False True.
Consider the code: a=21 b=6 print(a/b) print(a//b) print(a%b) What is the result? 3 3 3 3.5 3 3 3.5 3.5 3 3.0 3 3.
Consider the code a=1 b=2 c=4 d=6 Which of the following expression results in -4? (b+c)//a%d (a+b)//c*d (a+b)//c%d (a+b)//d-c.
In which of the following cases we will get different result ? 11/3 13//4 3**1 23%5 .
subjects=['java','python','sap'] more_subjects=['java','python','sap'] extra_subjects=more_subjects In which cases, True will be printed to the console? there are two options select any one print(subjects == extra_subjects) print(subjects is extra_subjects) print(extra_subjects is more_subjects) print(subjects is more_subjects).
Which of the following code snippet will produce the output: Boy Cat Dog There are two options select any one l=['Apple','Boy','Cat','Dog'] for x in l: if len(x) == 3: print(x) 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) l=['Apple','Boy','Cat','Dog'] for x in l: if len(x) != 3: print(x).
You are developing a python application for your company.A list named employees contains 500 employee names,the last 3 being company management. Which of the following represents only management employees. employees[-3:] employees[497:500] employees[497:] All the above.
Consider the code: x='ACROTE' y='APPLE' z='TOMATO' Which of the following won't print 'CAT' to the console print(x[1]+y[0]+z[0]) print(x[2]+y[1]+z[1]) print(x[-5]+y[0]+z[0]) print(x[-5]+y[0]+z[-2]).
Consider the following expression result=(2*(3+4)**2-(3**3)*3) What is result value? 16 18 19 17.
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 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)).
Consider the following statements: 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? only 1 and 2 only 1 and 3 only 2 and 4 1,2,3 and 4 .
We are developing a sports application. Our program should allow players to enter their names 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. 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)).
Consider the following code: 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? line-1 and line-2 should be changed there are two options select any one option for either line-1 or line-2 Line-1 should be replaced with while(index<10): Line-2 should be replaced with if numbers[index]==6: Line-2 should be replaced with if numbers[index]=6: Line-1 should be replaced with while(index>0):.
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. 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 It will throw an error because of the misuse of split() It will throw an error because of the misuse of isDigit() 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 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? 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) 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.
You are writing an application that uses the sqrt function. The program must reference the function using the name sq. Which of the following import statement required to use? import math.sqrt as sq import sqrt from math as sq from math import sqrt as sq from math.sqrt as sq.
Consider the code: import math l =[str(round(math.pi)) for i in range (1, 6)] print(l) #pi value = 3.14 What is the result? ['3', '3', '3', '3', '3'] ['3', '3', '3', '3', '3','3'] ['1', '2', '3', '4', '5'] ['1', '2', '3', '4', '5','6'].
You are writing code that generates a random integer with a minimum value of 5 and maximum value of 11. Which of the following 2 functions we required to use? There are two options select any one random.randint(5,12) random.randint(5,11) random.randrange(5,12,1) random.randrange(5,11,1).
Consider the following code: import random fruits=['Apple','Mango','Orange','Lemon'] Which of the following will print some random value from the list? There are two options select any one print(random.sample(fruits)) print(random.sample(fruits,3)[0]) print(random.choice(fruits)) print(random.choice(fruits)[0]).
We are developing an application for the client requirement.As the part of that we have to create a list of 7 random integers between 1 and 7 inclusive. Which of the following code should be used? import random randints=[random.randint(1,7) for i in range(1,8)] 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).
Consider the code: 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 not possible outputs? ApApAp ApMaOr LeMaOr OrOraM.
Report abuse Consent Terms of use