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
jenyasd209 [6]
3 years ago
11

Done through Block Py/ Python

Computers and Technology
1 answer:
34kurt3 years ago
3 0

Answer:

Following are the code to this question:

def rate_animal(an_animal):#defining method rate_animal

   if an_animal=="cat":#defining if block to check valu

       return 1 #return value 1

   elif an_animal=="dog":# defining elif block to check another value

       return 2 #return value 2

   elif an_animal=="capybara":# defining elif block to check another value

       return 3 #return value 3

   elif an_animal=="danger noodle":# defining elif block to check another value

       return 4 #return value 4

   else:

       return -1 #return value -1

print("dog Rating: ",rate_animal("dog"))#calling method and print its return value

print("cat Rating: ",rate_animal("cat"))#calling method and print its return value

print("capybara Rating: ",rate_animal("capybara"))#calling method and print its return value

print("danger noodle Rating: ",rate_animal("danger noodle"))#calling method and print its return value

print("Horse Rating: ",rate_animal("horse"))#calling method and print its return value

Output:

dog Rating:  2

cat Rating:  1

capybara Rating:  3

danger noodle Rating:  4

Horse Rating:  -1

Explanation:

Description of the python code can be defined as follows:

  • In the above program code, a method "rate_animal" is declared, in which a string variable "an_animal" passes as the argument, inside the method, multiple conditional statements are used.
  • In the if the block, it will check string value if it equal to "cat", it will return 1, otherwise, it will go to elif block, in this block it will check value is  "dog", "capybara", and "danger noodle", if the value is any of then it will return 2, 3, and 4.
  • If the above condition is not true, it will return a value, that is "-1", in the next step print method is used, that calls the method and print its return value.
You might be interested in
Create a goal seek analysis to determine what the price should be to generate demand of 2,625,000 tablets given that the supplie
Svetach [21]

Answer:

Explanation:

The following image shows the required entries that are to be filled in the excel sheet:

Goal Seek Parameters and Results

Set Cell                                        C14

To Value By Changing Cell        2625000

By Changing Cell                         C3

Resulting Price?                           $290

Explanation:

The goal seek tool in excel is used to change a value in the calculation to get the desired results.

In the given question, it is required to get the demand of tablets to reach the value of 2,625,000 by changing the price.

The value that is to be inserted in the “Set cell” field is the cell number which shall contain the desired result. This cell must have a formula having the cell which is inserted in the “by changing cell” field.

In the given question, the value of demand is desired.

The cell value which stores the calculated demand is C14 is and hence it is inserted in the field “Set cell”

The “to value” field of the goal seek tool is used to set the desired result.

Here, 2,625,000 is the value that is desired and hence it filled in the “To value” field.

The “By changing cell” field of the goal seek tool, represents the cell whose value is to be changed for getting the desired results.

Here, the value of price is required to be changed to get the required demand, thus the value that should be inserted in the “By changing cell” of the goal seek tool is C3, which represents the price.

The required demand is achieved by changing the price to $290.

8 0
3 years ago
Write a program that asks the user for a word. Next, open up the movie reviews.txt file and examine every review one at a time.
Hatshy [7]

Answer:

import numpy as np

word = input("Enter a word: ")

acc = []

with open("Downloads/record-collection.txt", "r") as file:

   lines = file.readlines()

   for line in lines:

       if word in line:

           line = line.strip()

           acc.append(int(line[0]))

   if np.mean(acc) >= 2:

       print(f"The word {word} is a positive word")

       print(f"{word} appeared {len(acc)} times")

       print(f"the review of the word {word} is {round(np.mean(acc), 2)}")

   else:

       print(f"the word {word} is a negative word with review\

{round(np.mean(acc), 2)}")

Explanation:

The python program gets the text from the review file, using the user input word to get the definition of reviews based on the word, whether positive or negative.

The program uses the 'with' keyword to open the file and created the acc variable to hold the reviews gotten. The mean of the acc is calculated with the numpy mean method and if the mean is equal to or greater than 2 it is a positive word, else negative.

5 0
3 years ago
How do I do this? I know the shapes and everything but how do I do b, d, and e?
aleksandr82 [10.1K]
Look in google for math flowcharts...it will appear easily.
4 0
3 years ago
In Excel, ____ is/are used to place worksheet, column, and row titles on a worksheet.
vladimir1956 [14]
In excel, [Text] is used to place worksheet, column and row titles on a worksheet.
In excel you can inset text to make comment, to input words or number and to make title. 
8 0
3 years ago
Dwayne wants a variable called "name" to appear in the interpreter and does not want a space after it. Which of these should be
ICE Princess25 [194]

Answer:

name + name

Explanation:

When assigning values to a Variable  in python, the + operator sums the values assigned to the variable into a single value hence there won't be any space between the values assigned .

Name + Name = NameName    in python programming

7 0
3 years ago
Other questions:
  • Determine the number of bytes necessary to store an uncompressed binary image of size 4000 × 3000 pixels.
    9·1 answer
  • Is Windows a:<br><br> A.operating system<br> B.software<br> C.hardware<br> D.input device
    12·1 answer
  • When a formula contains the address of a cell, it is called a(n)
    9·1 answer
  • What type of electronic monitoring involves an offender being contacted periodically by telephone or beeper to verify his or her
    5·1 answer
  • Which of the following subjects is considered technical education
    11·1 answer
  • Jenny needs to record the names of 30 students, write down the subjects they studied, and note grades in each subject after the
    13·2 answers
  • In terms of online safety, what is the grooming process, (predators).
    5·2 answers
  • Steve adds a second 1-GB 240-pin DIMM to his PC, which should bring the total RAM in the system up to 2GB. The PC has an Intel C
    9·1 answer
  • Write a test program that prompts the user to enter three sides of the triangle (make sure they define an actual triangle), a co
    5·1 answer
  • What are the two protocols used most often with iot devices? (select two. )
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!