








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









Evaluate each situation regarding data types and answer yes if its true or no if it is false - โโ-NO - When declaring variables in Python, a data type must be specified. YES - Python makes the distinction between integers and floating variables. YES - When setting a boolean variable, the value must start with a capital letter Look at the following code and indicate, for each area, the proper concatenating symbol. price = 18.00product = "Yellow Golf Balls"print(product [ ________ ] " are on sale for " [ _________ ] price ".") - โโ-" , " & " , " (COMMAS) Which variable names reflect an improper variable name declaration? Choose two answers - โโ-last- name last Name Drag the appropriate function to the missing code are to convert the price variable to a value of 19. inventoryCount = 19.
print("We have " ______ (inventoryCount)" complete units in stock.") - โโ-int Using drag and drop, drag the following lines of code into the correct order to produce this output: Bears Jaguars Lions Panthers - โโ-Step 1 - animals = ["Bears", "Lions", "Jaguars", "Tigers"] Step 2 - animals.append("Panthers") Step 3 - animals.remove("Tigers") Step 4 - animals.sort() Step 5 - for animal in animals: Step 6 - print (animal) From this code example: pieces = ["king", "queen", "rook", "bishop", "knight", "pawn"] pieces.sort() Which two commands will display the rock? - โโ-print(pieces[-1]) print(pieces[5])
Choose the correct operator to get a print result of 4. a = 24 b = 5 print(a _____ b) - โโ-% Look at the following code and then indicate, for each question, a yes or no answer based on whether the statement is true or false. a = 5 b = 3 b = a - โโ-YES - a == b YES - a is b NO - b == 3 Look at the following code and then select the correct keyword to use the check to see if the word "nine" is part of the quote. If this code runs, it should return a value of True. quote = "A stitch in time saves nine" print("nine" _____ quote) - โโ-in Drag in the correct order, lines of code that accomplish the following:
The messages "Great month" and "Keep it going" are printed for month sales over 1000. - โโ-1) if monthSales > 10000
The following code example needs to print, for five weeks, the number of minutes per day to walk, starting with 10 minutes a day in week 1 and ending with 50 minutes a day in week 5. Choose the correct line of code to start this iteration and finish the code example. - โโ-[[for week in range (1,6) ]] print("You should walk for ", week * 10, " minutes in ", week) Which keyword is used as a placeholder for a conditional result? - โโ-pass Complete the code example to build a function that does the following:
print ("Your order total is ", order1) Which line of code needs to be added to the top of this code example in order to complete the code example? - โโ-def calcTotal(amount, salesTax, shipping): Take a look at the following function: def subtotal(orderAmt, salesTax): subtotal = float(orderAmt) * (1 + float(salesTax)) return subtotal Which code example properly calls the function and returns a calculation? - โโ-orderTotal = subtotal(500, .07) In Python, which characters(s) should be placed before text in a line of code to make that line of code a comment? - โโ-# Take a look at the following code example: region = "West" annualSales = 500000 firstName = "Tony"
print("Decent year") else:: print("Better luck next year") print("Thank you for your efforts") print(f"Your sales representative is Nicole, you are in the East region, " [[ \ ]] "and you are based in the Potomac office.") Using drag and drop, drag over the lines of code that will accomplish the following:
print(jacketsFileContents) [[ jacketsFile.close() ]] In the following code example, select the snippet of code that will tell Python to read and print just the first line of the text file being opened. - โโ-workFile = open('work.txt', 'r') workFileFirstLine = [[ workFile.readline() ]] print(workFileFirstLine) A junior Python programmer wants to have a user input a location and then have the location print on the screen. In addition, the developer wants to tell the user to enter North, South, East, or West for a location. Using drag and drop, drag over the lines of code necessary to accomplish this. Not every line of code will be used. - โโ- 1 - location = input("Enter North, South, West, or East") 2 - print(location) The following code example, as is, prints "You have {items} items in stock" instead of the number of items in stock. Using the drop-down arrow, add the symbol needed to get the number of items to print instead of {items}. - โโ-price = 9. items= 15 print( [[ f ]] "We have {items} items in stock.")
licenseFee = 500 totalLoan = carLoan + licenseFee * intRate A user of the app with this code is complaining that the total loan amount is far lower than what is anticipated. What kind of error is taking place here? - โโ-Logic Examine the following code. What type of error could potentially occur, depending upon what a user inputs? x = float(input("Enter a number.")) y = float(input("Enter a number to divide by.")) print(f"The answer is {x/y}.") - โโ-Runtime The following code example does a simple calculation to divide two numbers. You want to handle any errors gracefully and ensure that the last print statement always prints, even if there is as an error. Using the drop-down arrows, fill in the missing keywords in the code to accomplish this. - โโ-FINISH THIS ONE POR FAVOR x = float(input("Enter a number. ")) y = float(input("Enter a number to divide by. ")) print(f"The answer is {x/y}.")
print("Uh oh. Did you enter something besides a number? Did you try to divide by zero?") print("You successfully played the division game.") print("Thank you for playing.")