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
ElenaW [278]
3 years ago
11

Write a Python function that takes a positive integer N and returns the factorial of N, i.e., N! The factorial of N, denoted N!,

is the product of the integers from 1 to N. (1 Point)
Computers and Technology
1 answer:
sesenic [268]3 years ago
6 0

Answer:

The python function is as follows:

def fact(N):

   factorial = 1

   for i in range(1,N+1):

       factorial = factorial * i

   return(factorial)

Explanation:

This line defines the function

def fact(N):

This line initializes the product of 1 to N to 1

   factorial = 1

This line iterates through 1 to N

   for i in range(1,N+1):

This line calculates the product of 1 to N i.e. factorial

       factorial = factorial * i

This line returns the factorial

   return(factorial)

You might be interested in
Funny or fascinating web content is said to go _________ when it is shared and re-shared a large number of times over a short pe
beks73 [17]
It is said to go viral?
4 0
3 years ago
For this portion of the lab you will design the solution so that you perform some conditional tests. For this lab: 1. You will v
PIT_PIT [208]

Answer:

#Prompt the user to enter the miles.

Miles = float(input('Enter the miles to convert into kilometer: '))

#Check the miles.

if Miles >= 0 :

   #Convert the miles to kilometers.

   Miles_To_km = Miles*1.6

   #Display the result.

   print (Miles, "miles equivalent to", Miles_To_km, "kilometer.")

   #Prompt the user to enter the gallons.

   Gallon = float(input('Enter the gallons to convert into liter: '))

   #Check the validity of the Gallons entered.

   if Gallon >= 0:

       #Convert gallons into liters.

       Gal_To_Lit = Gallon*3.9

       #Display the result.

       print (Gallon, "gallons equivalent to", Gal_To_Lit, "liters.")

       #Prompt the user to enter the pounds.

       Pound = float(input('Enter the pounds to convert into kilograms: '))

       #Check the validity of the Pounds entered.

       if Pound >= 0:

           #Convert pounds into kilograms.

           Pounds_To_Kg = Pound*0.45

           #Display the result.

           print (Pound, "pounds equivalent to", Pounds_To_Kg, "kilograms.")

           #Prompt the user to enter the temperature in Fahrenheit.

           f = float(input('Enter the temperature in Fahrenheit: '))

           #Check the value to be not greater than 1000.

           if f < 1000:

               #Convert Fahrenheit into celsius.

               F_To_C = (f -32)*5/9

               #Display the result.

               print (f, "Fahrenheit equivalent to", F_To_C, "celsius.")

           #Otherwise.

           else:

               

               #Display the error message.

               print ("Invalid temperature (greater than 1000) !!!")

       else:

           #Display the error message.

           print ("Pounds cannot be negative !!!")

   else:

           #Display the error message.

           print ("Gallons cannot be negative !!!")

else:

   #Display the error message.

   print ("Miles cannot be negative !!!")

Explanation:

4 0
4 years ago
My computer likes to disconnect every 3 or 5 minutes a lot when I turn it on, Is there any solution for this?
stira [4]

Answer:

RESTART IT!!! also check if its charged and look up problems with that model

Explanation:

5 0
3 years ago
Read 2 more answers
What things have small motors
aliya0001 [1]

Lots of things - your car has a engine that is used as a generator (your alternator). Cell phones that vibrate have a small electric motor with an uneven weight on the rotor which causes vibration ...

Hope this helps. :)

4 0
4 years ago
John just bought a used iPad from a friend who had lost the charging cable. John notices that the cable is like the charging cab
7nadin3 [17]

Answer:

an iphone charger

Explanation:

5 0
3 years ago
Other questions:
  • which kind of device does a computer need in order to provide information to a person or something else
    7·1 answer
  • If a firm is set to use open-source software with which no one in the IT department is familiar, what should it do? fire the IT
    14·2 answers
  • A user wants to quickly share pictures between mobile devices. The devices will be in close proximity so the necessity of a thir
    6·1 answer
  • You change a document that is saved on your computer by cutting text from the document what happens to the text when you preform
    5·1 answer
  • What have been three technological changes to photography in the past 200 years?
    10·1 answer
  • Each web site contains a(n) ____ page, which is the first document users see when they access the site.
    9·1 answer
  • Has anyone done the unit 10 lesson 9 encryption/decryption texts on code.org?
    15·1 answer
  • I AM GIVING BRAINLEST!!!!!!!!
    14·2 answers
  • You are implementing a RAID storage system and have found a system with eight 100 GB drives. How much storage space will you hav
    5·1 answer
  • How do you give people a brianly i am knew as u can tell
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!