Write a program that asks the user for the number of cats and the number of dogs registered in a course, storing the number of cats and dogs each in a variable. Print the percentage of cats in the course followed by a space and then print the percentage of dogs in the course.
Example: Suppose there are 8 cats and 12 dogs. There are 20 total animals in the class. The percentage of cats can be calculated as 100*(8 / 20) = 40.0. The percentage of dogs can be calculated as 100*(12 / 20) = 60.0.
I'm doing this on python.
Dear Student ,
As per requirement submitted above kindly find below solution.
Here new python program with name "catDogPercentage.py" is created which contains below code.
catDogPercentage.py :
#asking user for the number of cats registered
numberOfCats=int(input("Enter the number of cats registered :
"))
#asking user for the number of dogs registered
numberOfDogs=int(input("Enter the number of dogs registered :
"))
#calculate total animals
totalAnimals=numberOfCats+numberOfDogs
#calculate percentage of cats
print("{:0.1f}".format(100*(numberOfCats/totalAnimals)),"
","{:0.1f}".format(100*(numberOfDogs/totalAnimals)))
*********************************
Screen for indentation :
==================================
Output :Compile and run catDogPercentage.py to get the screen as shown below
Screen 1:catDogPercentage.py
NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
Write a program that asks the user for the number of cats and the number of...
Write a program that asks the user to input the number of males and females registered in a class (Max 30 members in the class). The program should display the percentage of males and females in the class. Python programming question
python program 6 Write an input validation loop that asks the user to enter a number in the range of 100 through 1000? 7 Write an input validation loop that asks the user to enter ‘Y’, ‘y’, ‘N’, or ‘n’? 8 How many times the following loop will repeat? cnt = 0 while cnt != 5: print(cnt) cnt = cnt + 2
Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...
USING PYTHON 1. Write a small program that asks for an integer number from the user and print all the prime numbers (2,3,5,7,etc) less than the input number. 2. How long it takes for your program to print the prime numbers less than 100. (Use magic functions)
Python Write a program which asks the user keep inputting values on a line followed by enter until they enter a blank line, at which point the program should print the number of lines entered (excluding the blank).
Write a Python program that asks the user to enter the number of calories and fat grams in a food item. The program should display the percentage of the calories that come from fat. One gram of fat has 9 calories, therefore: Calories from fat = fat grams * 9 The percentage of calories from fat can be calculated as follows: Calories from fat / total calories If the calories from fat are less than 30 percent of the total...
Python Programming 4th Edition: Write a program that asks the user for the number of feet. The program converts those feet to inches by using the formula ’12 * feet’. Hint: Define main () program Get the number of feet from the user Define variables Call a function feet_to_inches(feet) The function receives the number of feet and returns the number of inches in that many feet. The output should look like as follows: Enter the number of feet: If the...
Write a program that asks the user to enter a string and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string. python programming
Create a program that asks that asks the user for the number of males and females in a class. The program should display a percentage of males and females. For example, there are 5 males, and 15 females. That makes 20 people total. To find the percentage of males you can divide 5 by 20, which makes 0.25, or 25% HINT: USE A VARIABLE for every group of people that you will use in your calculation. Submit your .java source...
In Python, write a program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number. For example, if the user enters 10, the output would look something like this. https://www.vectorstock.com/royalty-free-vector/multiplication-table-on-white-background-vector-2721686