![CHENDESHEN](/avatars/49884.jpg)
CHENDESHEN
22.05.2020 •
Computers and Technology
Animals = ['aardvark', 'anteater', 'antelope', 'albert'] >>>animals[9999] Help, my teacher wants to me to explain what the output is and why for this python code, but I really don't know what to do for the second part. If we were just printing the "animals = ['aardvark', 'anteater', 'antelope', 'albert']" part it would be easy. However, I don't know about the >>>animals[9999] part. Apparently, the >>> is supposed to mean call function. Could someone explain what output would be and why?
Solved
Show answers
More tips
- C Computers and Internet How to Download Movies from Torrents?...
- F Food and Cooking How to Make the Perfect Glühwein: Step-by-Step Guide...
- A Animals and plants How to Grow Lime from a Seed: Simple Tips and Interesting Facts...
- S Style and Beauty How to Properly Tie a Tie: 5 Simple Steps...
- C Computers and Internet Dynamically Assigned IP Address: What Is It and How Does It Work?...
- C Computers and Internet How to Check the Speed of My Internet?...
- H Health and Medicine 5 Simple Steps to Quit Smoking for Good...
- C Computers and Internet How to Download Videos from YouTube? Simple Steps to Download Any Content...
- H Health and Medicine What is the Normal Blood Sugar Level in a Healthy Person?...
- S Style and Beauty How to Get Rid of Acne: Scientifically Proven Methods...
Answers on questions: Computers and Technology
- S Social Studies You can easily figure out how to communicate with your co workers as long as you know their ethnicity...
- H Health Teens diets a. rarely meet energy needs. b. tend to be low in calcium, iron, and riboflavin. c. tend to be nutrient-dense. d. usually meet all energy and nutrient...
- M Mathematics What are the solutions to the equation x² = 169? choose all answers that are correct...
- E English How might playwrights use of meter the audience...
- H Health 1- once a person’s red blood cells are all destroyed by hiv, a person develops aids. t or f? 2-which of the following ways can hiv not be transmitted? from a mother...
- H History What was one of the main problems facing the us during wwii...
- H History In 1960 what did scientist find in the centeral valley of mid ocean ridge...
- B Business Discuss the relationship between risk and insurance....
- B Biology If two different alleles for a trait are present and one allele doesn t entirely block the expression of the other, the genetic situation is calleda.recessiveb.co-dominancec.in-complete...
- A Advanced Placement (AP) Figurative language in the hobbit...
Ответ:
index out of range error
Explanation:
Not really. >>>animals[9999] implies that you need to type "animals[9999]" into the shell.
When you type animals[9999], you are trying access the 9998th element of the animals. Since there is not 9998th element in the list, you will get an index out of range error.
But let's say you want to access the first element in the list, then you would type animals[0] and it would print "aardvark".
Ответ:
public static int factorial(int n) {
if (n >= 1 && n <=12) {
if (n==1)
return 1;
else
return n * factorial(n-1);
}
else
return -1;
}
Explanation:
Create a method called factorial that takes one parameter, n
Check if n is n is between 1 and 12. If it is between 1 and 12:
Check if it is 1. If it is 1, return 1. Otherwise, return n * function itself with parameter n-1.
If n is not between 1 and 12, return -1, indicating that the number is not in the required range.
For example:
n = 3 Is n==1, NO factorial(3) = n*factorial(2)
n = 2 Is n==1, NO factorial(2) = n*factorial(1)
n = 1 Is n==1, YES factorial(1) = 1.
Then factorial(2) = 2*1 = 2, factorial(3) = 3*2 = 6