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
alex41 [277]
3 years ago
7

Write a python program to find factorial, use exception handling and display an appropriate message if the user inputs alphabets

instead of the number. Emulate Index error for a list and handle that exception. Find factorial for all numbers in a given list and display the result.
Computers and Technology
1 answer:
MrRissso [65]3 years ago
6 0

def func(lst):

   fac_lst = ([])

   try:

       for x in lst:

           i = 0

           fac = 1

           while i < x:

               fac *= (x - i)

               i += 1

           fac_lst.append(fac)

       return fac_lst

   except TypeError:

       return "Please input only numbers!"

   except IndexError:

       return "Please stay within the index!"

lst = ([1, 2, 3, 4, 5, 6, 7, 8])

print(func(lst))

I think this is what you're looking for. Best of luck.

You might be interested in
When you make taffy (a pliable candy), you must heat the candy mixture to 270 degrees Fahrenheit.
Sergeeva-Olga [200]

Explanation:

Here's my solution:

import java.util.Scanner; // We start by importing the Scanner, which enables us to put in values

public class Main // our class. Name doesn't really matter here.

{ // Open the brackets of the class.

   

public static void main(String[] args) { // This is our main method. It will run when we run the class.

    System.out.println("Starting Taffy Timer..."); // When we start the timer, we will print out that we do so

 Scanner re = new Scanner(System.in); // Import the scanner into the main method

 int temp; // Define the integer called temperature that the user will put in

 do { /* This is a do while loop -- it will go through the loop, and then it will check the value.

      I decided to use this because we can define temperature without checking the value first.

     What this loop is doing is taking in the temperature, and then checking if it's right. If

     it's a high enough temperature, it will tell the user that it's ready, but if not, it won't. */

     temp = re.nextInt(); // Allow the user to enter in the temperature

     if(temp >= 270) { // if it's high enough, say that it's ready

         System.out.println("Your taffy is ready for the next step!");

         

     }

     else { // if not, don't

          System.out.println("The mixture isn't ready yet.");

         

     }

 }

 while(temp < 270); // This makes sure that if it's ready for the next step, we don't have to continue

}

}

5 0
3 years ago
Explain approaches of AI​
Umnica [9.8K]
A-artificial I-intelligent
5 0
2 years ago
Read 2 more answers
How many free passes do you get for skipping videos and getting answers
blondinia [14]

Answer:

I think it is 1 because that is all that works for me

3 0
2 years ago
Write a SELECT statement that joins the Categories table to the Products table and returns these columns: category_name, product
Sphinxa [80]

Answer & Explanation:

1) Query:

SELECT Product_Name, Category_Name, List_Price

FROM Products AS P JOIN Categories AS C

ON C.Category_ID = P.Category_ID

ORDER BY Category_Name, Product_Name ASC;

2) Query:

SELECT C.Last_Name, C.First_Name, Order_Date, P.Product_Name, Item_Price, Discount_Amount, Quantity

FROM Customers AS C JOIN Orders AS O

ON C.Customer_ID = O.Customer_ID

JOIN Order_Items AS OI

ON O.Order_ID = OI.Order_ID

JOIN Products AS P

ON OI.Product_ID = P.Product_ID

ORDER BY Last_Name, Order_Date, Product_Name;

3) Query:

SELECT Category_Name, Product_ID

FROM Categories LEFT JOIN Products

ON Categories.Category_ID = Products.Category_ID

WHERE Product_ID IS NULL;

4) Query:

SELECT 'SHIPPED' AS Ship_Status, Order_Id, Order_Date

FROM Orders

WHERE Ship_Date IS NOT NULL

UNION

SELECT 'NOT SHIPPED' AS Ship_Status, Order_ID, Order_Date

FROM Orders

WHERE Ship_Date IS NULL

ORDER BY Order_Date;

3 0
3 years ago
This method adds newValue to the list at the specified index. If the index is invalid for the list, throw an IndexOutOfBoundsExc
EleoNora [17]

Answer:

i dont know

Explanation:

7 0
3 years ago
Other questions:
  • In addition to training on the products and on company policy, it does not make sense to be prepared to speak about your company
    6·2 answers
  • The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
    13·1 answer
  • Explain briefly the purpose of the Computer Management Console in Microsoft Windows.
    12·1 answer
  • Higher-speed Ethernet technologies use an electronic device known as a Hub rather than a switch True/False
    15·1 answer
  • Which one is correct
    8·1 answer
  • Write two cin statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a dash,
    7·1 answer
  • Will mark Brainliest!! What is the best hard disk compacity? Why?
    7·1 answer
  • Calculate the heat energy required to raise the temperature of 5 kg of water from 20℃ to
    5·1 answer
  • Types of digital divide ​
    15·1 answer
  • Vector images take up much less space when saved to a computer or storage device because computers and storage devices just need
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!