98-381 Python Exam

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Consider the code x=3 x +=1 #Line-1 Which line should be inserted at Line-1 so that x value will become 16? Options are : x**=2 x*=2 x+=2 x-=2

A

Consider the following code: v1 = 1 v2 = 0 v1 = v1 ^ v2 v2 = v1 ^ v2 v1 = v1 ^ v2 print(v1) What is the result? Options are : A. 0 B. 3 C. 2 D. 1

A

In which of the following cases, True will be printed to the console ? (Choose two) Options are : A. print('r' in 'Larry') B. print('is' in 'This IS a Fake News') C. a=45 b=45 print(a is not b) D. x=[1,2,3] y=[1,2,3] print(x is y) E. s1='The Python Course' s2='The Python Course'.upper() print(s1 is s2)

AB

Consider the variable declaration b = 'BANANA' Which of the following lines will print 'AA' to the console? (Choose 3) Options are : A.print(b[1]+b[3]) B. print(b[1]+b[5]) C. print(b[1]+b[2]) D. print(b[3]+b[5])

ABD

Consider the code count=input('Enter the number of customers of the bank:') #Line-1 print(output) Which code inserted at Line-1 will print 20 to the console if we pass 15 as count value from the console? Options are : A. output=str(count)+5 B. output=int(count)+5 C. output=float(count)+5 D. output=count+5

B

Consider the code: from sys import argv print(argv[0]) and given the command invocation: py test.py SampleText What is the result? Options are : A. ImportError will be thrown at runtime B. test.py C. IndexError will be thrown at runtime D. SampleText

B

Consider the values: a=7 b=3 c=5 d=1 Which line of the code assigns 9 to the output? Options are : A. output=a%c+1 B. output=a+d*2 C. output=c*d-1 D. output=a+c//d

B

The ABC company has hired you as an intern on the coding team that creates e-commerce applications.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.You need to write the code to meet the requirements.Which code segment should you use? A. totalItems = input("How many items would you like?") B. totalItems = float(input("How many items would you like?")) C. totalItems = str(input("How many items would you like?")) D. totalItems = int(input("How many items would you like?"))

B

Which expression evaluates to 4? Options are : A. 7/2*3 B. 7%2+3 C. 7//2-3 D. 7-2*3

B

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 Name:') #Line-1 print(name) At Line-1, which code we have to write Options are : A. input(name) B. name=input() C. name=input D. input('name')

B

You develop a Python application for your company.You need to accept input from the user and print that information to the user screen.You have started with the following code. Line numbers are included for reference only 01 print("What is your name?") 02 03 print(name) Which code should you write at line 02? A. name = input B. input("name") C. input(name) D. name = input()

B

You are writing code that generates a random integer with a minimum value of 5 and a maximum value of 11.Which two functions should you use? Each correct answer presents a complete solution. (Choose two.) A. random.randint(5, 12) B. random.randint(5, 11) C. random.randrange(5, 12, 1) D. random.randrange(5, 11, 1)

BC

Which of the following are valid statements? (Choose 2) Options are : A. type('') is B. True and False evaluates to False C. True or False evaluates to False D. True+1 evaluates to 2 E. 5+False evaluates to False

BD

You develop a Python application for your company.A list named employees contains 200 employee names, the last five being company management. You need to slice the list to display all employees excluding management.Which two code segments should you use? Each correct answer presents a complete solution. (Choose two.) A. employees [1:-4] B. employees [:-5] C. employees [1:-5] D. employees [0:-4] E. employees [0:-5]

BE

Consider the Code x=3/3+3**3-3 print(x) What is the output? Options are : A. 0.11 B. 25 C. 25.0 D. 32

C

Evaluate the following Python arithmetic expression: (3*(1+2)**2-(2**2)*3) A. 3 B. 13 C. 15 D. 69

C

Given the command invocation:py test.py AlexWhich of the following code prints 'Alex' to the console? Options are : A. from sys import argv print(argv[0]) B. from sys import args print(args[1]) C. from sys import argv print(argv[1]) D. from sys import args print(args[0])

C

You are writing an application that uses the sqrt function. The program must reference the function using the name squareRoot.You need to import the function.Which code segment should you use? A. import math.sqrt as squareRoot B. import sqrt from math as squareRoot C. from math import sqrt as squareRoot D. from math.sqrt as squareRoot

C

You develop a Python application for your school.You need to read and write data to a text file. If the file does not exist, it must be created. If the file has content, the content must be removed.Which code should you use? A. open("local_data", "r") B. open("local_data", "r+") C. open("local_data", "w+") D. open("local_data", "w")

C

You are creating a function that manipulates a number. The function has the following requirements:-> A float is passed into the function-> The function must take the absolute value of the float-> Any decimal points after the integer must be removedWhich two math functions should you use? Each correct answer is part of the solution. (Choose two.) A. math.fmod(x) B. math.frexp(x) C. math.floor(x) D. math.ceil(x) E. math.fabs(x)

CE

Consider the code a=float('123.456') Which expression evaluates to 2? Options are : A. int(a)+False B. str(a) C. bool(a) D. bool(a)+True

D

Consider the following expression: 6//4%5+2**3-2//3 This expression results in: Options are : A. -1 B. 25 C. 3 D. 9

D

You are intern for XYZ Cars Company. You have to create a function that calculates the average velocity of 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 most precise output, which modifications should be done at Line-1 and at Line-2. Options are : A. yyy should be replaced with int and yyy should be replaced with int B. yyy should be replaced with int and yyy should be replaced with float C. yyy should be replaced with float and yyy should be replaced with int D. yyy should be replaced with float and yyy should be replaced with float

D

You are intern for XYZ Cars Company. You have to create a function that calculates the average velocity of 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 most precise output, which modifications should be done at Line-1 and at Line-2. Options are : A. yyy should be replaced with int and yyy should be replaced with int B. yyy should be replaced with int and yyy should be replaced with float C. yyy should be replaced with float and yyy should be replaced with int D. yyy should be replaced with float and yyy should be replaced with float

D


Ensembles d'études connexes

Intro to Entrepreneurship: Chapter 3

View Set

PMI Agile Certified Practitioner (PMI-ACP)

View Set

PN 140 Test 4 Practice Questions

View Set

Health Test Chapter 7, 8, and 9 Review Mr. Sloan

View Set