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
Will robots take people's jobs? <br> write in complete sentence.
lilavasa [31]

Answer:

yes

Explanation:

yes because they already have them for old gun ships (which they still use) and they have made cars with them and more including bombing situations IED detinators they used in Afghanistan and in Iraq in 2011.

6 0
3 years ago
Give several reasons why Python is such a great programming language. Explain how Python is related to flowcharts. (students mak
Mekhanik [1.2K]

It is great but that's really it.

Don't get me wrong I adore Python, no complications, pure simplicity, wonderful community. But for any larger project that will be scaled I'd never use it. It's slow (mostly because of GIL) and gets pretty hard to organise once you have thousands of .py files but it's still a great language (my first one) when doing quick prototyping, personal projects, learning and it's also AI de facto programming language because of its readability works as a glue with AI.

It's related to flowchart in a way we write algorithms, for eg. in python we rarely use counter in for loop the inverse is thus C++ where most for loops are for loops not for each loops.

Hope this helps.

3 0
4 years ago
The information that a program requires in order to accomplish its objective is called the.
ivolga24 [154]

The information that a program requires in order to accomplish its objective is called input.

<h3>What is a program?</h3>

A program is a set of instructions by which the computer performs various tasks. The program is a sequence of instructions that are followed by the computer to run. An example is Microsoft Word.

A computer program comes under software. The sequence code of a program that is readable by humans is called source code. The program is run by information that is called input.

Thus, the data that a program needs in order to achieve its goal is referred to as input.

To learn more about the program, refer to the below link:

brainly.com/question/14368396

#SPJ4

8 0
2 years ago
What can save a computer from damage by sudden increases in voltage?
Simora [160]
Surge protector :) hope this helps
7 0
3 years ago
There is an increasing need for private security personnel because of declining resources for many government agencies and a sho
aivan3 [116]
<span>True
</span><span>There is an increasing need for private security personnel because of declining resources for many government agencies and a shortage of police officers in many communities due to lack of funding.

</span>
8 0
4 years ago
Other questions:
  • Which of the following is not a typical step in the ethical hacking process? A. Planning B. Discovery C. Attack D. Recovery
    5·1 answer
  • Which command can be used to manually add a package to the driver store?
    13·1 answer
  • What is required for real-time surveillance of a suspects computer activity?/p Group of answer choices a. Blocking data transmis
    12·1 answer
  • Your mom wants to purchase a computer. She has heard about how the Windows 8 operating system is best-geared for a touch-enabled
    10·2 answers
  • Which keyword should return web pages about guitars and about guitarists?
    11·1 answer
  • What lets you do many things, like write book reports and stories?
    5·1 answer
  • A red wavy line under a word means _____. a change has been made in the text a new word was inserted in the document there is a
    11·2 answers
  • Which of the following is an accurate definition of a computer system? A computer system consists of the operating system that t
    6·1 answer
  • Def pig_latin(word): """ ------------------------------------------------------- Converts a word to Pig Latin. The conversion is
    15·1 answer
  • Who is known as Father of Computer?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!