All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Hire a Tutor
AI Study Help
New
Search
Search
Sign In
Register
study help
computer science
starting out with python
Questions and Answers of
Starting Out With Python
Write a program that asks the user to enter a distance in kilometers, then converts that distance to miles. The conversion formula is as follows: Miles = Kilometers X 0.6214
Write a function named shout. The function should accept a string argument and display it in uppercase with an exclamation mark concatenated to the end.
What is a function?
A design technique that helps to reduce the duplication of code within a program and is a benefit of using functions is __________.a. Code reuseb. Divide and conquerc. Debuggingd. Facilitation of
True or FalseFunctions make it easier for programmers to work in teams.
Name and describe the two parts of a function definition.
Examine the following function header, then write a statement that calls the function, passing 12 as an argument.def show_value(quantity):
Python allows you to repeat a string by multiplying it by an integer, e.g. 'Hi' * 3 will give 'HiHiHi'. Pretend that this feature does not exist, and instead write a function named repeat that
What is meant by the phrase “divide and conquer”?
The first line of a function definition is known as the __________.a. Bodyb. Introductionc. Initializationd. Header
True or FalseFunction names should be as short as possible.
When a function is executing, what happens when the end of the function block is reached?
Look at the following function header:def my_function(a, b, c):Now look at the following call to my_function:my_function(3, 2, 1)When this call executes, what value will be assigned to a? What value
Many financial experts advise that property owners should insure their homes or buildings for at least 80 percent of the amount it would cost to replace the structure. Write a program that asks the
How do functions help you reuse code in a program?
You __________ a function to execute it.a. Defineb. Callc. Importd. Export
True or FalseCalling a function and defining a function mean the same thing.
What will the following program display? def main (): X = 1 y = = 3.4 print (x, y) change_us (x, y) print (x, y) def change_us (a, b): a = 0 b = 0 print (a, b) main()
What is a local variable? What statements are able to access a local variable?
Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance. The
How can functions make the development of multiple programs faster?
A design technique that programmers use to break down an algorithm into functions is known as __________.a. Top-down designb. Code simplificationc. Code refactoringd. Hierarchical subtasking
The ___________ operator takes a Boolean expression as its operand and reverses its logical value.a. Andb. Orc. Notd. Either
Convert the following code to an if-elif-else statement: if number == 1: print('one')
What would the following code display? if 'z' < 'a': print('z is less than a.') print('z is not less than a.') else:
What would the following code display?s1 = 'New York's2 = 'Boston' if s1 > s2: print (s2) print (s1) else: print (s1) print (s2)
Figure 3-19 shows a simplified flowchart for troubleshooting a bad Wi-Fi connection. Use the flowchart to create a program that leads a person through the steps of fixing a bad Wi-Fi connection. Here
The Fast Freight Shipping Company charges the following rates:Write a program that asks the user to enter the weight of a package then displays the shipping charges. Weight of Package 2 pounds or
What is a compound Boolean expression?
The month of February normally has 28 days. But if it is a leap year, February has 29 days. Write a program that asks the user to enter a year. The program should then display the number of days in
You have a group of friends coming to visit for your high school reunion, and you want to take them out to eat at a local restaurant. You aren’t sure if any of them have dietary /restrictions, but
Enhance the hit_the_target.py program that you saw in Program 3-9 so that, when the projectile misses the target, it displays hints to the user indicating whether the angle and/or the force value
Explain how short-circuit evaluation works with the and and or operators.
What values can you assign to a bool variable?
What is a flag variable?
How do you get the turtle’s X and Y coordinates?
How would you determine whether the turtle’s pen is up?
How do you get the turtle’s current heading?
How do you determine whether the turtle is visible?
How do you determine the turtle’s pen color? How do you determine the current fill color? How do you determine the current background color of the turtle’s graphics window?
How do you determine the current pen size?
How do you determine the turtle’s current animation speed?
True or FalseA condition-controlled loop always repeats a specific number of times.
What is a repetition structure?
A __________ -controlled loop uses a true/false condition to control the number of times that it repeats.a. Booleanb. Conditionc. Decisiond. Count
What is a condition-controlled loop?
A bug collector collects bugs every day for five days. Write a program that keeps a running total of the number of bugs collected during the five days. The loop should ask for the number of bugs
What is a condition-controlled loop?
A __________ -controlled loop repeats a specific number of times.a. Booleanb. Conditionc. Decisiond. Count
What is a count-controlled loop?
Running on a particular treadmill you burn 4.2 calories per minute. Write a program that uses a loop to display the number of calories burned after 10, 15, 20, 25, and 30 minutes.
What is a count-controlled loop?
Write a for loop that uses the range function to display all odd numbers between 1 and 100.
True or FalseThe following statement subtracts 1 from x: x = x − 1
What is a loop iteration?
The while loop is a __________ type of loop.a. Pretestb. No-testc. Prequalifiedd. Post-iterative
How are an accumulator variable and a loop used to calculate a running total?
Starting with a variable text containing an empty string, write a loop that prompts the user to type a word. Add the user’s input to the end of text and then print the variable. The loop should
Does the while loop test its condition before or after it performs an iteration?
How many iterations would occur in total if a loop that repeats 5 times is nested within a loop that repeats 4 times?
How many times will 'Hello World' be printed in the following program? count = 10 while count < 1: print('Hello World')
The -= operator is an example of a(n) __________ operator.a. Relationalb. Augmented assignmentc. Complex assignmentd. Reverse assignment
Rewrite the following statements using augmented assignment operators.a. x = x + 1b. x = x * 2c. x = x / 10d. x = x − 100
What is an infinite loop?
True or FalseThe process of input validation works as follows: when the user of a program enters invalid data, the program should ask the user “Are you sure you meant to enter that?” If the user
What does the phrase “garbage in, garbage out” mean?
Write a set of nested loops that displays the first ten values of the multiplication tables from 1 to 10. The code should print 100 lines in total, starting at “1 * 1 = 1” and ending with “10 *
Rewrite the following code so it calls the range function instead of using the list [0, 1, 2, 3, 4, 5]: for x in [0, 1, 2, 3, 4, 5]: print('I love to program!')
Give a general description of the input validation process.
What will the following code display?for number in range(6):print(number)
Write code that prompts the user to enter a positive nonzero number and validates the input.
GIGO stands for __________.a. Great input, great outputb. Garbage in, garbage outc. GIGahertz Outputd. GIGabyte Operation
Assume the variables result, w, x, y, and z are all integers, and that w = 5, x = 4, y = 8, and z = 2. What value will be stored in result after each of the following statements execute?a. Result = x
A customer in a store is purchasing five items. Write a program that asks for the price of each item, then displays the subtotal of the sale, the amount of sales tax, and the total. Assume the sales
What is a flowchart?
A __________ is a diagram that graphically depicts the steps that take place in a program.a. Flowchartb. Step chartc. Code graphd. Program graph
True or FalseIf you print a variable that has not been assigned a value, the number 0 will be displayed.
Write a Python statement that assigns the product of 10 and 15 to the variable product.
A __________ is a sequence of characters.a. Char sequenceb. Character collectionc. Stringd. Text block
What is a magic number? Why are magic numbers problematic?
Write a Python statement that subtracts the variable down_payment from the variable total and assigns the result to the variable due.
Write a statement that displays your name.
Write a Python statement that multiplies the variable subtotal by 0.15 and assigns the result to the variable total.
A __________ is a name that references a value in the computer’s memory.a. Variableb. Registerc. RAM slotd. Byte
A __________ is any hypothetical person using a program and providing input for it.a. Designerb. Userc. Guinea pigd. Test subject
What would the following display?a = 5b = 2c = 3result = a + b * cprint(result)
Write a program that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, then calculate the amounts of a 18 percent tip
Write a statement that displays the following text:The cat said "meow."
A string literal in Python must be enclosed in __________.a. Parentheses.b. Single-quotes.c. Double-quotes.d. Either single-quotes or double-quotes.
What would the following display?num = 99num = 5print(num)
Short notes placed in different parts of a program explaining how those parts of the program work are called __________.a. Commentsb. Reference manualsc. Tutorialsd. External documentation
Assume the variable sales references a float value. Write a statement that displays the value rounded to two decimal points.
A cookie recipe calls for the following ingredients:• 1.5 cups of sugar• 1 cup of butter• 2.75 cups of flourThe recipe produces 48 cookies with this amount of the ingredients. Write a program
A(n) __________ makes a variable reference a value in the computer’s memory.a. Variable declarationb. Assignment statementc. Math expressiond. String literal
Assume the following statement has been executed:number = 1234567.456Write a Python statement that displays the value referenced by the number variable formatted as1,234,567.5
This symbol marks the beginning of a comment in Python.a. &b. *c. **d. #
What will the following statement display?print('X\tO\tXO\tX\tOX\tO\tX')
Is the following assignment statement valid or invalid? If it is invalid, why? 72 = amount
Which of the following statements will cause an error?a. x = 17b. 17 = xc. x = 99999d. x = '17'
A vineyard owner is planting several new rows of grapevines, and needs to know how many grapevines to plant in each row. She has determined that after measuring the length of a future row, she can
Showing 400 - 500
of 839
1
2
3
4
5
6
7
8
9