Write a loop that continually asks the user what pets the user has, until the user enters "rock", in which case the loop ends. It should acknowledge the user in the following format. For the first pet, it should say "You have a dog with a total of 1 pet(s)" if they enter dog, and so on. Sample Run:
User enters:
lemur parrot cat rock
Outputs:
You have a lemur with a total of 1 pet(s)
You have a parrot with a total of 2 pet(s)
You have a cat with a total of 3 pet(s)

Answers

Answer 1
Answer:

Following are the python program to use the loop to count the number of pets until the user enters the "rock":

Program:

c = 0#defining a variable c that initilzes with 0

p = input()#defining a variable p that input value

while p != 'rock':#defining a loop that check p value not equal to rock

  c += 1#using c variable for counts total number of pets

  print('You have a %s with a total of %d pet(s)' %(p,c))#print total number of pet

  p = input() #input value

Output:

Please find the attached file.

Program Explanation:

  • Defining a variable "c" that is initialized with 0, which is used to count input values.
  • In the next line, a "p" variable is declared as the input value from the user end.
  • A while loop is declared to check that the p-value is not equal to 'rock'.
  • Inside this loop, the "c" variable is used for counting the total number of pets, and a print method is used to print the total number of pets.
  • Another input method is used that works until the user inputs the value that is "rock".

Find out more about the loop here:

brainly.com/question/17067964


Related Questions

What is the center of mass of the assembly? a) X=‐11.05 Y=24.08 Z=‐40.19 b) X=‐11.05 Y=‐24.08 Z=40.19 c) X= 40.24 Y=24.33 Z=20.75 d) X= 20.75 Y=24.33 Z=40.24
For selection purposes, it is critical that application items have a proven relationship between a selection device and some relevant criterion. This is called
You are an administrator for the Contoso Corporation. You have client software that receives its configuration from a shared folder. Therefore, you need to make sure that this shared folder is highly available. Since is used by hundreds of users, many at the same time, you want to make sure that performance is high. What would you do
Seasons Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day. Ex: If the input is April 11, the output is: spring In addition, check if the string and int are valid (an actual month and day). Ex: If the input is invalid, the output is: invalid The dates for each season are: spring: March 20 - June 20 summer: June 21 - September 21 autumn: September 22 - December 20 winter: December 21 - March 19
Write a program to calculate how much to tip a waiter person based on the quality of service. The script file should ask for the amount of the check and whether the service was good, fair or poor. If the service was good, the tip should be 20%. If the service was fair, the tip should be 15%. If the service was poor, the tip should be 5%. The program should display the tip and the total of the check including the tip.

Which of the following function declarations correctly expect an array as the first argument?Question 1 options:

void f1(int array, int size);

void f1(int& array, int size);

void f1(int array[100], int size);

void f1(float array[], int size);

All of the above

C and D

A and B

Answers

Answer:

Only

Option: void f1(float array[], int size);

is valid.

Explanation:

To pass an array as argument in a function, the syntax should be as follows:

functionName (type arrayName[ ] )

We can't place the size of the array inside the array bracket (arrayName[100]) as this will give a syntax error. The empty bracket [] is required to tell the program that the value that passed as the argument is an array and differentiate it from other type of value.

A constructor (check all that apply): Group of answer choices will always result in a run time error and program crash if it fails to test a parameter's value for validity before assigning the parameter's value to member. This will happen the first time we run a program, and alert us to the fact that there is a problem. must use mutators to initialize class data. must use assignment statements to initialize class data. may use assignment statements to initialize class data. may use mutators to initialize class data. will receive a compiler error if it fails to test a parameter's value for validity before assigning the parameter's value to member.

Answers

Answer:

Must use mutators to initialize class data.

May use assignment statements to initialize class data.

Explanation:

These are the two characteristics that are present in constructors. A constructor is an instance method of a class or structure that creates an object of the class to which it belongs. This is mostly used in object-oriented programming. These constructors usually have the same name as the actual class, and can be used in order to set the values of the members of an object.

If you are looking for a keyboard to project from a device to a flat surface, which of the following would you use?

Answers

a virtual keyboard perhaps

Write a program that takes user input describing a playing card in the following short-hand notation:А Ace
2... 10 Card values
J Jack
Q Queen
K King
D Diamonds
H Hearts
S Spades
C Clubs

Your program should print the full description of the card. For example, Enter the card notation: QS Queen of Spades
Implement a class Card whose constructor takes the card notation string and whose getDescription method returns a description of the card. If the notation string is not in the correct format, the getDescription method should return the string "Unknown".

Answers

Answer:

In python Language:

cardNotation = raw_input("Enter card notation: ")

 

# Create a dict for values

 

cardColors = {"D": "Diamonds",

             "H": "Hearts",

             "S": "Spades",

             "C": "Clubs"}

 

cardNumberValues = {"A": "Ace",

                   "J": "Jack",

                   "Q": "Queen",

                   "K": "King",

                   "2": "Two",

                   "3": "Three",

                   "4": "Four",

                   "5": "Five",

                   "6": "Six",

                   "7": "Seven",

                   "8": "Eight",

                   "9": "Nine",

                   "10": "Ten"}

 

# Handle cases when 10 comes in input

if len(cardNotation) == 3:

 

   number = cardNotation[:2]

   color = cardNotation[2:]

   print cardNumberValues.get(number) + " of " + cardColors.get(color)

 

elif len(cardNotation) == 2:

 

   number = cardNotation[:1]

   color = cardNotation[1:]

   print cardNumberValues.get(number) + " of " + cardColors.get(color)

 

else:

   print "INVALID VALUE"

In cell B13, create a formula without a function using absolute references that subtracts the values of cells B5 andB7 from cell B6 and then multiples the result by cell B8. please help with excel!! I'm so lost

Answers

Answer:

The formula in Excel is:

=($B$6 - $B$5 - $B$7)* $B$8

Explanation:

Required

Use of absolute reference

To reference a cell using absolute reference, we have to include that $ sign. i.e. cell B5 will be written as: $B$5; B6 as $B$6; B7 as $B$7; and B8 as $B$8;

Having explained that, the formula in cell B13 is:

=($B$6 - $B$5 - $B$7)* $B$8

Illustrator : how do you edit a swatch ?​

Answers

Answer:

To edit an existing pattern, double-click the pattern in the pattern swatch, or select an object containing the pattern and choose Object > Pattern > Edit Pattern