1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Roman55 [17]
2 years ago
6

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 sh

ould 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

Computers and Technology
1 answer:
mote1985 [20]2 years ago
6 0

Loops are program statements that are repeated as long as the loop condition is true.

The loop in Python, where comments are used to explain each line is as follows:

#This initializes the number of pets to 0

count = 0

#This gets input for the pet name

pet = input("Pet: ")

#This is repeated until the user enters "rock"

while pet.lower() != "rock":

   #This increases the number of pets by 1

   count+=1

   #This prints the pet and the number of pets

   print("You have a",pet,"with a total of",str(count),"pet(s)")

   #This gets input for the pet name

   pet = input("Pet: ")

Read more about loops at:

brainly.com/question/19344465

You might be interested in
Drag each label to the correct location on the image.
expeople1 [14]

Answer:

Black is the absence of all light. Things appear black when they do not reflect or emit light. White is the presence of all colors of visible light. Objects appear white when they reflect or emit all wavelengths of visible light (or at least three wavelengths - Red, Blue and Green - in equal intensity).

Explanation:

6 0
3 years ago
Which type of financial institution typically has membership requirements?
zheka24 [161]
The answer is online commercial banking :)
7 0
4 years ago
Read 2 more answers
Be able to list a technology-based company and discuss whether it enjoys sustainable competitive advantage based on the resource
aev [14]

Answer:

idk good luck finding one

5 0
3 years ago
1. Extract title Write a function extract_title that takes one parameter, the filename of a GenBank formatted file, and returns
trapecia [35]

Answer:

def extract_title(file):

   import re

   a =''

   with open(file,'r') as file:

       for line in file:

           a += line

       m = re.search("^(TITLE)(.*?)(JOURNAL)", a, re.M + re.S)

       print(m.groups()[1])

extract_title('new.txt')

Explanation:

The programming language used is python 3.

The function is first defined and the regular expression module is imported.

A variable is initialized to an empty string that will hold the content of the GenBank formatted file.

The file is opened and every line in the file is assigned to the string variable. The WITH statement allows files to be closed automatically.

Regular expression is used to capture all the files between TITLE and JOURNAL in a group.

The group is printed and the function is called.

I have attached a picture of the code in action.

6 0
3 years ago
Write a function named last_digit that returns the last digit of an integer. For example, last_digit(3572) should return 2. It s
Vika [28.1K]

def last_digit(num):

   num = str(num)

   return int(num[-1])

print(last_digit(-947))

I hope this helps!

6 0
3 years ago
Other questions:
  • Judy forgot where she saved a certain file on her computer. Therefore, she searches for all files with a .jpg file extension. Wh
    10·2 answers
  • . Two or more functions may have the same name, as long as their _________ are different.
    9·1 answer
  • What does the Additional Clock tab do?
    11·1 answer
  • "Managers and department heads across the nation strategize on a weekly, if not daily, basis. For the past three quarters, telep
    6·1 answer
  • Which is an example of an incremental approach to solving a problem?
    15·1 answer
  • What is the correct order of headers, from left to right, in a completed frame?
    8·1 answer
  • Java !!!
    10·1 answer
  • What was the name of the first personal computer and what year was it introduced
    7·1 answer
  • Please help me plss! PLS​
    8·2 answers
  • You're doing desktop support and the company policy is that you can only help with company equipment. A user walks in:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!