Python Programming Studio

Look at the ASCII chart in Appendix C and determine the codes for each letter of your first name. 6. Use the Internet to research the history of the Python programming language, and answer the following questions Who was the creator of Python In rhe Python programming community, the person who created Python is commonly referred to as rhe BDFL. What does this mean

Using a Sentinel

The county tax office calculates the annual taxes on property using the following formula property tax property value X 0.0065 Every day, a clerk in the tax office gets a list of properties and has to calculate the tax for each property on the list. You have been asked to design a program that the clerk can use to perform these calculations. In your interview with the tax clerk, you learn that each property is assigned a lot number, and all lot numbers are 1 or greater. You decide to write a...

Working with Strings

CONCEPT Python provides several ways to access the individual characters in a string. Strings also have methods that allow you to perform operations on them. Many of the programs that you have written so far have worked with strings, but only in a limited way. The operations that you have performed with strings so far have primarily involved only input and output. For example, you have read strings as input from the keyboard and from files, and sent strings as output to the screen and to files....

The while Loop a Condition Controlled Loop

CONCEPT A condition-controlled loop causes a statement or set of statements to repeat as long as a condition is true. In Python you use the while statement to write a condition-controlled loop. The while loop gets its name from the way it works while a condition is true, do some task. The loop has two parts (1) a condition that is tested for a true or false value, and (2) a statement or set of statements that is repeated as long as the condition is true. Figure 5-1 shows the logic of a while...

Reading Input from the Keyboard

- CONCEPT Programs commonly need to read input typed by the user on the keyboard. We will use the Python functions to do this. Most of the programs that you will write will need to read input, and then perform an operation on that input. In this section, we will discuss a basic input operation reading data that has been typed on the keyboard. When a program reads data from the keyboard, usually it stores that data in a variable so it can be used later by the program. In this book we will use...

Python Formula Average Miles Per Gallon

76 Create an instance of the MyGUI class. 12-25 Window displayed by Program 12-1 3 12-25 Window displayed by Program 12-1 3 r Option 1 f* Option 2 P Option 3 OK I Quit r Option 1 f* Option 2 P Option 3 OK I Quit 12.15 You want the user to be able to select only one item from a group of items. Which type of component would you use for the items, radio buttons or check boxes 12.16 You want the user to be able to select any number of items from a group of items. Which type of component would you...

The ifelifelse Statement

Even though Program 4-6 is a simple example, the logic of the nested decision structure is fairly complex. Python provides a special version of the decision structure known as the if - elif-else statement, which makes this type of logic simpler to write. Here is the general format of the if-elif-else statement if condition-1 statement statement etc. elif condition-2 statement statement etc. Insert as many elif clauses as necessary When the statement executes, condition is tested. If conditional...

Review Questions

The_________programming practice is centered on creating functions that are separate from the data that they work on, programming practice is centered on creating objects. is a component of a class that references data. 5. By doing this you can hide a class's attribute from code outside the class. a. avoid using the self parameter to create the attribute b. begin the attribute's name with two underscores c. begin the name of the attribute with private d. begin the name of the attribute with...

Info

F is rhe Fahrenheit temperature and C is the Celsius temperature. A county collects property taxes on the assessment value of property, which is 60 percent of the property's actual value. If an acre of land is valued at 10,000, its assessment value is 6,000. The property tax is then 0.64 for each 100 of the assessment value. The tax for the acre assessed at 6,000 will be 38.40. Write a GUI program that displays the assessment value and property rax when a user enters the actual value of a...

CPU

This process is repeated for each high-level instruction. The statements that a programmer writes in a high-level language are called source code, or simply code. Typically, the programmer types a program's code into a text editor and then saves the code in a file on the computer's disk. Next, the programmer uses a compiler to translate the code into a machine language program, or an interpreter to translate and execute the code. If the code contains a syntax error, however, it cannot be...

Designing a Program to Use Functions

CONCEPT Programmers commonly use a technique known as top-down design to break down an algorithm into functions. Flowcharting a Program with Functions In Chapter 2 we introduced flowcharts as a tool for designing programs. In a flowchart, a function call is shown with a rectangle that has vertical bars at each side, as shown in Figure 3-8. The name of the function that is being called is written on the symbol. The example shown in Figure 2-8 shows how we would represent a call to the message...

More About Data Output

When this statement executes, it displays Python recognizes several escape characters, some of which are listed in Table 2-7. Table 2-7 Some of Python's escape characters n Causes output to be advanced to the next line. t Causes output to skip over to the next horizontal tab position. Causes a single quote mark to be printed. Causes a double quote mark to be printed. Causes a backslash character to be printed. The t escape character advances the output to the next horizontal tab position. A tab...

Programming Exercises

Assume that a file containing a series of integers is named numbers . txt and exists on the computer's disk. Write a program that displays all of tlie numbers in the file. Write a program that asks rhe user for rhe name of a file. The program should display only the first five lines of the file's contents. If the file contains less than five lines, it should display the file's entire contents. Write a program that asks the user for the name of a file. The program should display the contents of...

Nested Decision Structure Can Be Used To Test More Than One Condition

Nested Decision Structures

The flowchart in the figure starts with a sequence structure. Assuming you have an outdoor thermometer in your window, the first step is Go to the window, and the next step is Read thermometer. A decision structure appears next, testing the condition Cold outside. If this is true, the action wear a coat is performed. Another sequence structure appears next. The step Open the door is performed, followed by Go outside. Quite often, structures must be nested inside other structures. For example,...

Python Average Rainfall Program

Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall...

Software Company Sells A Package That Retails For 99 Python Program

The area of a rectangle is the rectangle's length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the greater area, or if the areas are the same. Scientists measure an object's mass in kilograms and its weight in newtons. If you know rhe amount of mass of an object in kilograms, you can calculate its weight in newtons with the following formula Write a program that asks the user to enter an object's...

Design A Program That Asks The User To Enter A Store S Sales For Each Day Of The Week

Alphabetic Telephone Number Translator Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion A, B, and C 2 D, E, and F 3 G, H, and I 4 J, K, and L 5 M, N, and O 6 P, Q, R, and S 7 T, U, and V 8 W, X, Y, and Z 9 Write a program that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should...

Python Write A Program That Asks The User To Enter The Number Of Packages Purchased

Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of rhe discount if any and the total amount of the purchase after the discount. The Fast Freight Shipping Company charges the following rates Weight of Package Rate per Pound Over 2 pounds but not more than 6 pounds 2.20 Over 6 pounds but not more than 10 pounds 3.70 Write a program that asks the user to enter the weight of a package and then displays the shipping charges, 7....

Using IPO Charts

Ipo Charts Programming

An IPO chart is a simple but effective tool that programmers sometimes use for designing and documenting functions. IPO stands for input, processing, and output, and an IPO chart describes the input, processing, and output of a function. These items are usually laid out in columns the input column shows a description of the data that is passed to the function as arguments, the processing column shows a description of the process that the function performs, and the output column describes the...

Hardware and Software

Major Components Computer

The physical devices that a computer is made of are referred to as the computer's hardware. The programs that run on a computer are referred to as software. The term hardware refers to all of the physical devices, or components, that a computer is made of. A computer is not one single device, but a system of devices that all work together. Like the different instruments in a symphony orchestra, each device in a computer plays its own part. If you have ever shopped for a computer, you've...

Adding the Python Directory to the Path Variable

If you plan to execute the Python interpreter from a command prompt window, you will probably want to add the Python directory to the existing contents of your system's Path variable. You saw the name of the Python directory while installing Python. It is something similar to C Python25. Doing this will allow your system to find the Python interpreter from any directory when you run it at the command-line. Use the following instructions to edit the Path variable under Windows XP and Windows...

You Are To Write A Program That Calculates The Amount Of Money A Person Would Earn Over A Period Of Time If His Or Her

Where F is the Fahrenheit temperature and C is the Celsius temperature. Your program must use a loop to display the table. Write a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing what the salary was for each day, and then show the total pay at the end of the period. The...

What Design Technique Can Be Used To Break Down An Algorithm Into Functions

2 5 Call the main function. 2 6 main Program Output with input shown in bold Enter the gross pay 80000.00 Enter Enter the amount of bonuses 20000.00 Enter Contribution for gross pay 4000.00 Contribution for bonuses 1000.00 Firsr, notice rhe global variable that is created in line 3 This variable will be used as a global constant to represent the percentage of an employee's pay that the company will contribute to a retirement account. It is a common practice to write a constant's name in all...

An Informal Language That Has No Syntax Rules And Is Not Meant To Be Compiled Or Executed Is Called

A ---error does not prevent the program from running, but causes it to 2. A-is a single function that the program must perform in order to satisfy the 3. A u --is a set of well-defined logical steps that must be taken to perform a 4. An informal language that has no syntax rules, and is not meant to be compiled or executed is called---- 5. A _ is a diagram that graphically depicts rhe steps that take place in a 6. A_is a sequence of characters. 7. A-is a name that references a value in the...