Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, Can someone please answer all questions? Thank you. Background Programs tend to involve the user to input data. We can get string on Python

Hello,

Can someone please answer all questions? Thank you.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Background Programs tend to involve the user to input data. We can get string on Python with the input() function and convert to other types by using other function such as int(), float(), and bool(). Variables are names given to data that we need to store for later. After a variable is defined in a program, a certain area of the computer is assigned to store this data. A value associated to a variable can be updated by specifying the name of the variable and the new value. As procedural programs are very much a sequence of executed instructions, the exact order of when we store (or replace) a value for a variable, and when we look up and use the current value, is an important part of understanding how to create the solution to a programming task In this project, the user is asked to input values of various types, which are stored in different variables. Then, the program performs basic operations to display results with the function print() onto the terminal window. In this project only are used variables, operations and expression. Control structures will be explored on future projects. The task of this project is to solve a variant of the famous "Rhind papyrus problem 79" Restrictions You can ask for additional functionality to be allowed, but the chances are slim that we will approve it. The general theme is, the interesting parts of the assignment must be completed by the student, not built-in functions. Allowed things: Any arithmetic operators are all fine to use, such as +, -, *, 7, %, and, or, >, 95% that it's not allowed. 1 Procedure The task of this project is coding a program in Python to solve a variant of the "Rhind papyrus problem 79" In a scholar bus, there are w children, each child carries x boxes, in each box there are y cats. If each cat has z kittens. How many individuals are on the bus? What percentage is that of children and animals of the total individuals? How many legs are in total? What percentage is that of children and animals of the total legs? Create your python file, following the instructions from the project basics file. Perform the following actions in your code (in exact order!), storing their answers as needed in variables. 1. Greet the user with the message, "Welcome to the kitt-cat Riddle!" 2. Ask the user: "What is your name?" 3. Ask the user: "How many children are in the bus?" 4. Ask the user: "How many boxes does each child carry?" 5. Ask the user: "How many cats are in each box?" 6. Ask the user: "How many kittens does each cat have?" 7. Compute the total cats 8. Compute the total kittens 9. Compute the total individuals, and display it to the user. Show the number of children, cats and kittens a. Display the percentage of children b. Display the percentage of animals using subtraction 10. Compute the total animal legs 11. Compute the total children legs 12. Compute the total legs, and display it to the user. Show the number of children's legs and animals' legs a. Display the percentage of children's legs b. Display the percentage of animals' legs using subtraction 13. Tell the user... We solved the riddle [name]! Assumptions In computer science evant formattinofinnut loutnutie lile putting on socle with shoes while people might Assumptions In computer science exact formatting of input/output is like putting on socks with shoes, while people might not do it 100% of the time in their personal life, it is extremely unusual not to do it in a professional setting. Therefore, you will need to format your input/output exactly like the samples provided. As we are just starting to program, and don't even have if-else statements at our disposal, we will assume many things to make the project easier, though it makes the project slightly more artificial. You may assume the following: The user will always enter an integer when we ask for an integer, etc. Every number the user enters will be a positive number when testing this project. To calculate percentages use the function round(). Calculate the children's percentages first and use subtraction to calculate animals' percentages. 2 Example Suppose we have 2 children carrying 2 boxes. Each box has 1 cat who has 2 kittens. We Example Run In the examples below, green text starting with 'demo$' is the operating system's prompt (demo) and the com- mand you write to run python (python3 code.py), blue underlined text is the input given by the user, and pur- ple text is the output that your program generates: demo$ python3 kittcat_P1.py Welcome to the kitt-cat Riddle! What is your name? David How many children are in the bus? 2 How many boxes does each child carry? 2 How many cats are in each box? 1 How many kittens does each cat have? 2 There are 14 individuals in the bus: 2 children, 4 cats and 8 kittens From the total individuals, 14% are children and 86% animals There are 52 legs: 4 children's legs and 48 animals' legs From the total legs, 8% are children's and 92% animals' We solved the Riddle David! demos Testing Your Code The tester for this project expects exact matching to pass a test case. If you're getting the right numbers but failing test cases, check for spacing issues, capitalization, spelling errors, and so on - look closely, and you can figure it out! You get to see the exact tests we'll use when we grade your code, so you might as well get them all correct before turning in your work! No surprises there. One note, the OUTPUT section of the tests only includes what the program is supposed to print, and does not include the characters that a user would be typing during the interaction (including when the user hits enter for a newline) makes the output look a weird, but the testing file is correct. To test your code with the provided tester, first make sure that you have downloaded the files "testerP1.py" and "testsP1.txt" into the same folder as your project code. Then, from that directory, run the following command: demo$ python3 testerP1.py user_2xx_P1.py passed 15/15 tests. If you pass all of the tests, you will see the above contents. If you don't pass a test, you will be informed of where the mismatch in your output is, and you can figure out from there what needs to be fixed. Testing Your Code The tester for this project expects exact matching to pass a test case. If you're getting the right numbers but failing test cases, check for spacing issues, capitalization, spelling errors, and so on look closely, and you can figure it out! You get to see the exact tests we'll use when we grade your code, so you might as well get them all correct before turning in your work! No surprises there. One note, the OUTPUT section of the tests only includes what the program is supposed to print, and does not include the characters that a user would be typing during the interaction (including when the user hits enter for a newline). This makes the output look a bit weird, but the testing file is correct. To test your code with the provided tester, first make sure that you have downloaded the files "testerP1.py" and "testsP1.txt" into the same folder as your project code. Then, from that directory, run the following command: demo$ python3 testerP1.py user_2xx_P1.py passed 15/15 tests. If you pass all of the tests, you will see the above contents. If you don't pass a test, you will be informed of where the mismatch in your output is, and you can figure out from there what needs to be fixed. 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Master The Art Of Data Storytelling With Visualizations

Authors: Alexander N Donovan

1st Edition

B0CNMD9QRD, 979-8867864248

More Books

Students also viewed these Databases questions