0% found this document useful (0 votes)
32 views4 pages

Lab 6 7

The document describes 14 programming exercises involving tasks like calculating areas of rectangles, determining a person's age group, converting numbers to Roman numerals, and more. The final exercise involves writing a program to recommend restaurants based on whether any friends in a party have dietary restrictions like being vegetarian, vegan, or gluten-free. The program would ask the user about each restriction and display only restaurants that can accommodate all restrictions.

Uploaded by

nranjeet049
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views4 pages

Lab 6 7

The document describes 14 programming exercises involving tasks like calculating areas of rectangles, determining a person's age group, converting numbers to Roman numerals, and more. The final exercise involves writing a program to recommend restaurants based on whether any friends in a party have dietary restrictions like being vegetarian, vegan, or gluten-free. The program would ask the user about each restriction and display only restaurants that can accommodate all restrictions.

Uploaded by

nranjeet049
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

LAB-6-7

1. Write a python code to draw the following designs.

2. Day of the Week


Write a program that asks the user for a number in the range of 1 through 7. The program should display
the corresponding day of the week, where 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 =
Friday, 6 = Saturday, and 7 = Sunday. The program should display an error message if the user enters a
number that is outside the range of 1 through 7.

3. Areas of Rectangles
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.

4. Age Classifier
Write a program that asks the user to enter a person’s age. The program should display a message
indicating whether the person is an infant, a child, a teenager, or an adult.
Following are the guidelines:
• If the person is 1 year old or less, he or she is an infant.
• If the person is older than 1 year, but younger than 13 years, he or she is a child.
• If the person is at least 13 years old, but less than 20 years old, he or she is a
teenager.
• If the person is at least 20 years old, he or she is an adult.

5. Roman Numerals
Write a program that prompts the user to enter a number within the range of 1
through 10. The program should display the Roman numeral version of that
number. If the number is outside the range of 1 through 10, the program should
display an error message.
6. Color Mixer

The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing
other colors. When you mix two primary colors, you get a secondary color, as shown here:
When you mix red and blue, you get purple.
When you mix red and yellow, you get orange.
When you mix blue and yellow, you get green.
Design a program that prompts the user to enter the names of two primary colors to mix. If the user enters
anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise,
the program should display the name of the secondary color that results.

7. Hot Dog Cookout Calculator

Assume hot dogs come in packages of 10, and hot dog buns come in packages of 8. Write a program that
calculates the number of packages of hot dogs and the number of packages of hot dog buns needed for a
cookout, with the minimum amount of leftovers. The program should ask the user for the number of
people attending the cookout and the number of hot dogs each person will be given. The program should
display the following details:
• The minimum number of packages of hot dogs required
• The minimum number of packages of hot dog buns required
• The number of hot dogs that will be left over
• The number of hot dog buns that will be left over

8. Roulette Wheel Colors


On a roulette wheel, the pockets are numbered from 0 to 36. The colors of the pockets are as follows:
• Pocket 0 is green.
• For pockets 1 through 10, the odd-numbered pockets are red and the even-numbered pockets are black.
• For pockets 11 through 18, the odd-numbered pockets are black and the even-numbered pockets are red.
• For pockets 19 through 28, the odd-numbered pockets are red and the even-numbered pockets are black.
• For pockets 29 through 36, the odd-numbered pockets are black and the even-numbered pockets are red.

Write a program that asks the user to enter a pocket number and displays whether the pocket is green, red,
or black. The program should display an error message if the user enters a number that is outside the
range of 0 through 36.

9. Money Counting Game

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, and
quarters. If the total value of the coins entered is equal to one dollar, the program should congratulate the
user for winning the game. Otherwise, the program should display a message indicating whether the
amount entered was more than or less than one dollar.
10.Book Club Points

Serendipity Booksellers has a book club that awards points to its customers based on the number of books
purchased each month. The points are awarded as follows:

• If a customer purchases 0 books, he or she earns 0 points.


• If a customer purchases 2 books, he or she earns 5 points.
• If a customer purchases 4 books, he or she earns 15 points.
• If a customer purchases 6 books, he or she earns 30 points.
• If a customer purchases 8 or more books, he or she earns 60 points.

Write a program that asks the user to enter the number of books that he or she has purchased this month,
then displays the number of points awarded.

11. Software Sales


A software company sells a package that retails for $99. Quantity discounts are given according to the
following table:
Quantity Discount
10–19 10%
20–49 20%
50–99 30%
100 or more 40%
Write a program that asks the user to enter the number of packages purchased. The program should then
display the amount of the discount (if any) and the total amount of the purchase after the discount.

12. Shipping Charges

The Fast Freight Shipping Company charges the following rates: Weight of Package Rate per Pound
2 pounds or less $1.50
Over 2 pounds but not more than 6 pounds $3.00
Over 6 pounds but not more than 10 pounds $4.00
Over 10 pounds $4.75
Write a program that asks the user to enter the weight of a package then displays the shipping charges.

13. Body Mass Index


Write a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to
determine whether a person is overweight or underweight for his or her height. A person’s BMI is
calculated with the following formula: BMI 5 weight 3 703/height2 where weight is measured in pounds
and height is measured in inches. The program should ask the user to enter his or her weight and height,
then display the user’s BMI. The program should also display a message indicating whether the person
has optimal weight, is underweight, or is overweight.
A person’s weight is considered to be optimal if his or her BMI is between 18.5 and 25. If the BMI is less
than 18.5, the person is considered to be underweight. If the BMI value is greater than 25, the person is
considered to be overweight.

You have a group of friends coming to visit for your high school reunion, and you want
14. Restaurant Selector

To take them out to eat at a local restaurant. You aren’t sure if any of them have dietary
restrictions, but your restaurant choices are as follows:

Joe’s Gourmet Burgers—Vegetarian: No, Vegan: No, Gluten-Free: No


Main Street Pizza Company—Vegetarian: Yes, Vegan: No, Gluten-Free: Yes
Corner Café—Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes
Mama’s Fine Italian—Vegetarian: Yes, Vegan: No, Gluten-Free: No
The Chef’s Kitchen—Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes

Write a program that asks whether any members of your party are vegetarian, vegan, or
gluten-free, to which then displays only the restaurants to which you may take the group.
Here is an example of the program’s output:

Is anyone in your party a vegetarian? yes Enter


Is anyone in your party a vegan? no Enter
Is anyone in your party gluten-free? yes Enter

Here are your restaurant choices:

Main Street Pizza Company


Corner Cafe
The Chef's Kitchen

Here is another example of the program’s output:

Is anyone in your party a vegetarian? yes Enter


Is anyone in your party a vegan? yes Enter
Is anyone in your party gluten-free? yes Enter

Here are your restaurant choices:

Corner Cafe
The Chef's Kitchen

You might also like