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
True or FalseYou can have more than one except clause in a try/except statement.
A file exists on the disk named students.txt. The file contains several records, and each record contains two fields: (1) the student’s name, and (2) the student’s score for the final exam. Write
Write a program that asks the user how many words they would like to write to a file, and then asks the user to enter that many words, one at a time. The words should be written to a file.
What is the purpose of opening a file?
When working with this type of file, you can jump directly to any piece of data in the file without reading the data that comes before it.a. Ordered accessb. Binary accessc. Direct accessd.
True or FalseThe else suite in a try/except statement executes only if a statement in the try suite raises an exception.
A file exists on the disk named students.txt. The file contains several records, and each record contains two fields: (1) the student’s name, and (2) the student’s score for the final exam. Write
This exercise assumes you have completed the Programming Exercise 7, Word Lis File Writer. Write another program that reads the words from the file and displays the following data:• The number of
What is the purpose of closing a file?
This is a small “holding section” in memory that many systems write data to before writing the data to a file.a. Bufferb. Variablec. Virtual filed. Temporary file
What will the following code display? try: x = float ('abc123') print('The conversion is complete.') except IOError: print('This code caused an IOError.') except ValueError: print('This code caused a
True or FalseThe finally suite in a try/except statement executes only if no exceptions are raised by statements in the try suite.
Modify the program that you wrote for Exercise 6 so it handles the following exceptions:• It should handle any IOError exceptions that are raised when the file is opened and data is read from
What will the following code display? try: x = float (abc123) print (x) except ValueError: print('This code caused a ValueError.') except TypeError: print('This code caused a TypeError.') print('This
This marks the location of the next item that will be read from a file.a. Input positionb. Delimiterc. Pointerd. Read position
The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you to write two programs:1. A program that will read each player’s name and golf score as keyboard
Write a program that asks the user for his or her name, then asks the user to enter a sentence that describes himself or herself. Here is an example of the program’s screen:Once the user has
In what mode do you open a file if you want to write data to it, but you do not want to erase the file’s existing contents? When you write data to such a file, to what part of the file is the data
When a file is opened in this mode, data will be written at the end of the file’s existing contents.a. Output modeb. Append modec. Backup moded. Read-only mode
Write a short program that uses a for loop to write the numbers 1 through 10 to a file.
This is a single piece of data within a record.a. Fieldb. Variablec. Delimiterd. Subrecord
A Personal Fitness Tracker is a wearable device that tracks your physical activity, calories burned, heart rate, sleeping patterns, and so on. One common physical activity that most of these devices
What does it mean when the readline method returns an empty string?
Assume the file data.txt exists and contains several lines of text. Write a short program using the while loop that displays each line in the file.
Revise the program that you wrote for Checkpoint 6.14 to use the for loop instead of the while loop.Checkpoint 6.14Assume the file data.txt exists and contains several lines of text. Write a short
You write this statement to respond to exceptions.a. Run/handleb. Try/exceptc. Try/handled. Attempt/except
Write a Python statement that defines a named constant for a 10 percent discount.
What is the turtle’s default heading when it first appears?
How do you move the turtle forward?
How would you turn the turtle right by 45 degrees?
How would you move the turtle to a new location without drawing a line?
What command would you use to display the turtle’s current heading?
What command would you use to draw a circle with a radius of 100 pixels?
What command would you use to change the turtle’s pen size to 8 pixels?
What command would you use to change the turtle’s drawing color to blue?
What command would you use to change the background color of the turtle’s graphics window to black?
What command would you use to set the size of the turtle’s graphics window to 500 pixels wide by 200 pixels high?
What command would you use to move the turtle to the location (100, 50)?
What command would you use to display the coordinates of the turtle’s current position?
Which of the following commands will make the animation speed faster? turtle. speed(1) or turtle.speed(10)
What command would you use to disable the turtle’s animation?
Describe how to draw a shape that is filled with a color.
How do you display text in the turtle’s graphics window?
A __________ structure can execute a set of statements only under certain circumstances.a. sequenceb. circumstantialc. decisiond. Boolean
You can write any program using only sequence structures.
Write an if statement that assigns 20 to the variable y, and assigns 40 to the variable z if the variable x is greater than 100.
Write a program that asks the user to enter an integer. The program should display “Positive” if the number is greater than 0, “Negative” if the number is less than 0, and “Zero” if the
What is a control structure?
A __________ structure provides one alternative path of execution.a. Sequenceb. Single alternative decisionc. One path alternatived. Single execution decision
A program can be made of only one type of control structure. You cannot combine structures.
Explain how a single alternative decision structure and a dual alternative decision structure differ.
Write an if statement that assigns 10 to the variable b, and 50 to the variable c if the variable a is equal to 100.
What is a decision structure?
A(n) __________ expression has a value of either True or False.a. Binaryb. Decisionc. Unconditionald. Boolean
A single alternative decision structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.
Write an if-else statement that assigns 0 to the variable b if the variable a is less than 10. Otherwise, it should assign 99 to the variable b.
Write a program that asks the user for a month as a number between 1 and 12. Theprogram should display a message indicating whether the month is in the first quarter,the second quarter, the third
What is a single alternative decision structure?
The symbols >,
The following code contains several nested if-else statements. Unfortunately, it was written without proper alignment and indentation. Rewrite the code and use the proper conventions of alignment and
A decision structure can be nested inside another decision structure.
What is a Boolean expression?
A(n) _________ structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.a. If statementb. Single alternative decisionc. Dual alternative
A compound Boolean expression created with the and operator is true only when both subexpressions are true.
What types of relationships between values can you test with relational operators?
You use a(n) __________ statement to write a single alternative decision structure.a. Test-jumpb. Ifc. If-elsed. If-call
What is a flag and how does it work?
Write an if-else statement that assigns True to the again variable if the score variable is within the range of 40 to 49. If the score variable’s value is outside this range, assign False to the
The date June 10, 1960, is special because when it is written in the following format, the month times the day equals the year:6/10/60Design a program that asks the user to enter a month (in numeric
How does a dual alternative decision structure work?
A compound Boolean expression created with the _________ operator is true if either of its subexpressions is true.a. Andb. Orc. Notd. Either
Write an if statement that uses the turtle graphics library to determine whether the turtle is inside of a rectangle. The rectangle’s upper-left corner is at (100, 100) and its lower-right corner
Create a change-counting game that gets the user to enter the number of coins required to make exactly one dollar. The program should prompt the user to enter the number of pennies, nickels, dimes,
When you write an if-else statement, under what circumstances do the statements that appear after the else clause execute?
Write code that prompts the user to enter a number in the range of 1 through 100 and validates the input.
Assuming the ocean’s level is currently rising at about 1.6 millimeters per year, create an application that displays the number of millimeters that the ocean will have risen each year for the next
What will the following code display?for number in range(2, 6):print(number)
The integrity of a program’s output is only as good as the integrity of the program’s __________.a. Compilerb. Programming languagec. Inputd. Debugger
At one college, the tuition for a full-time student is $8,000 per semester. It has been announced that the tuition will increase by 3 percent each year for the next 5 years. Write a program with a
What will the following code display?for number in range(0, 501, 100):print(number)
The input operation that appears just before a validation loop is known as the __________.a. Prevalidation readb. Primordial readc. Initialization readd. Priming read
A “sleep debt” represents the difference between a person’s desirable and actual amount of sleep. Write a program that prompts the user to enter how many hours they slept each day over a period
What will the following code display?for number in range(10, 5, −1):print(number)
Validation loops are also known as ___________.a. Error trapsb. Doomsday loopsc. Error avoidance loopsd. Defensive loops
What is an accumulator?
In this chapter, you saw an example of a loop that draws a square. Write a turtle graphics program that uses nested loops to draw 100 squares, to create the design shown in Figure 4-13. Figure 4-13
Should an accumulator be initialized to any specific value? Why or why not?
Use a loop with the turtle graphics library to draw the design shown in Figure 4-14. Figure 4-15 Hypnotic pattern
Rewrite the following statements using augmented assignment operators:a) Quantity = quantity + 1b) Days_left = days_left − 5c) Price = price * 10d) Price = price / 2
What is a sentinel?
In this chapter, you saw an example of a loop that draws an octagon. Write a program that uses the loop to draw an octagon with the word “STOP” displayed in its center. The STOP sign should be
Why should you take care to choose a distinctive value as a sentinel?
What does the phrase “garbage in, garbage out” mean?
Give a general description of the input validation process.
Describe the steps that are generally taken when an input validation loop is used to validate data.
What is a priming read? What is its purpose?
If the input that is read by the priming read is valid, how many times will the input validation loop iterate?
A group of statements that exist within a program for the purpose of performing a specific task is a(n) __________.a. Blockb. Parameterc. Functiond. Expression
True or FalseThe phrase “divide and conquer” means that all of the programmers on a team should be divided and work in isolation.
How do functions help facilitate teamwork?
Showing 300 - 400
of 839
1
2
3
4
5
6
7
8
9