Question

Using Python Assigns the value of “dog” to the variable AnimalName. Assigns the value of “pigeon”...

Using Python

  1. Assigns the value of “dog” to the variable AnimalName.
  2. Assigns the value of “pigeon” to the variable AltAnimal.
  3. Includes an if-statement in which… (Hint: You should use both elif and else.)
    1. If the value of AnimalName is “cat”, prints “The animal is a cat.”
      1. Includes a comment on the same line as this if-statement that explains what the if-statement is looking for (i.e., what would have to be true for the statement to return “true”).
    2. If the value of AnimalName is the same as AltAnimal, prints “The animal is a [value of AltAnimal].”
    3. Or, if the AnimalName is “lemur”, prints “I am displeased with the value of AnimalName.”
    4. But otherwise prints “The animal is not a cat or [value of AltAnimal]. Apparently it is a [value of AnimalName].”
  4. Use placeholders to insert the variable values into your print statements.

Homework Answers

Answer #1

#Python code

AnimalName="dog"
AltAnimal="pigeon"
if AnimalName is "cat":       #check if value of AnimalName is cat
    print("The animal is a cat.")
elif AltAnimal is AnimalName:
    print("The animal is a %s."%(AltAnimal))
elif AnimalName is "lemur":
    print("I am displeased with the value of AnimalName.")
else:
    print("The animal is not a cat or %s. Apparently it is a %s."%(AltAnimal,AnimalName))

OUTPUT

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using Python Assigns the value “Phil” to the variable SomeName. Uses the len function and the...
Using Python Assigns the value “Phil” to the variable SomeName. Uses the len function and the SomeName variable to assign the number of letters in Phil’s name to the variable NameLength. Outputs the following using a print statement (the print statement should output the quotation marks and the values of the SomeName and NameLength variables where indicated by the [brackets]): “I very much enjoy infinite loops,” said [value of SomeName], whose name is [value of NameLength] letters long. Use placeholders...
ON PYTHON Exercise 1. For each of the relational/logical expressions listed in exercise1.py determine whether the...
ON PYTHON Exercise 1. For each of the relational/logical expressions listed in exercise1.py determine whether the expression evaluates to True or False. Place a comment after each expression with the truth value and submit the updated exercise1.py file to the dropbox. For example, x = 10 y = 11 x < y # True  insert a comment after the expression x = 10 y = 11 a = 12.5 b = -5.2 x < y # True x <...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features the design of a calculator program using pseudocode and a Python program that uses a list and functions with variable scope to add, subtract, multiply, and divide. Open the M4Lab1ii.py program in IDLE and save it as M4Lab1ii.py with your initials instead of ii. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and...
convert this code to accept int value instead of float values using python. Make sure to...
convert this code to accept int value instead of float values using python. Make sure to follow the same code. do not change the steps and make sure to point to what code you replaced. make sure to have 2 files Method:----------------------- #define a python user difined method def get_float_val (prompt): is_num = False str_val = input (prompt) #prming read for our while #while is_num == False: (ignore this but it works) old school while not is_num: try: value =...
python problem: ( use a loop to read each character from the string and insert into...
python problem: ( use a loop to read each character from the string and insert into the stack) 1. The function main a5.py continually asks the user for a string, and calls isPalindrome to check whether each string is a palindrome. A palindrome is a word or sequence that reads the same backward as forward, e.g., noon, madam or nurses run. 2. Your function must ignore spaces: when the user enters 'nurses run', the function returns True, to indicate that...
Draw a flowchart based on the Python code below: ch = -1 #Variable declared for taking...
Draw a flowchart based on the Python code below: ch = -1 #Variable declared for taking option entered by the user print("Enter 0 to 5 for following options: ") print("0-> Issue new ticket number.") print("1-> Assign first ticket in queue to counter 1.") print("2-> Assign first ticket in queue to counter 2.") print("3-> Assign first ticket in queue to counter 3.") print("4-> Assign first ticket in queue to counter 4.") print("5-> Quit Program.") tickets = [] #Declaring list to store...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance:...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance: ⦁   A base class called Pet ⦁   A mix-in class called Jumper ⦁   A Dog class and a Cat class that each inherit from Pet and jumper ⦁   Two classes that inherit from Dog: BigDog and SmallDog ⦁   One classes that inherit from Cat: HouseCat The general skeleton of the Pet, Dog, and BigDog classes will be given to you (see below, "Skeleton", but...
Please answer this using def (functions) in python 3 with a single print statement under #main....
Please answer this using def (functions) in python 3 with a single print statement under #main. Is this possible to do in one print as output? User specifies the number of books ordered, and if the order is online, or not. You can collect the second input by asking the user to enter 1 for online, and 0 for offline. You can assume that the user will enter 1 or 0 as directed. Unit price for a book is 15$....
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
0. Introduction. In this laboratory assignment, you will write a Python class called Zillion. The class...
0. Introduction. In this laboratory assignment, you will write a Python class called Zillion. The class Zillion implements a decimal counter that allows numbers with an effectively infinite number of digits. Of course the number of digits isn’t really infinite, since it is bounded by the amount of memory in your computer, but it can be very large. 1. Examples. Here are some examples of how your class Zillion must work. I’ll first create an instance of Zillion. The string...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT