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
Allushta [10]
4 years ago
13

Write a program that asks the user to input a positive integer and then calculates and displays the factorial of the number. The

program should call a function named getN
Computers and Technology
1 answer:
mestny [16]4 years ago
6 0

Answer:

<em>The program is written in python and it doesn't make use of any comment; </em>

<em>(See explanation section for line by line explanation)</em>

def getN(num):

     fact = 1

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

           fact = fact * i

     print("Factorial: ",fact)

num = int(input("Number: "))

if num < 0:

     print("Invalid")

else:

     getN(num)

Explanation:

The function getNum is defined here

def getN(num):

Initialize the result of the factorial to 1

     fact = 1

Get an iteration from 1 to the user input number

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

Multiply each number that makes the iteration

           fact = fact * i

Print result

     print("Factorial: ",fact)

Ths line prompts user to input number

num = int(input("Number: "))

This line checks if user input is less than 0; If yes, the program prints "Invalid"

if num < 0:

     print("Invalid")

If otherwise, the program calls the getN function

else:

     getN(num)

You might be interested in
The three main types of banks (Large Traditional, Credit Union, Online or Online-Only) have many tradeoffs with respect to techn
Margarita [4]
So from a little research, this is the order:
Online Bank, Credit Union, Traditional Bank

Online bank is the highest one since it uses technology like the internet to transfer money or to pay bills easily.
Credit union is same as an online bank where it also uses internet offering mobile and online banking services.
Traditional bank is the most common type of bank. They also offer mobile banking but they still use the old procedure of banking like depositing and withdrawing money, face to face.
5 0
3 years ago
Read 2 more answers
With a ____ indent, all lines except the first line of the paragraph are indented from the left margin.
hoa [83]

The answer to this question is a hanging indent. A hanging indent is a writing format where in the first line of the text or paragraph is being aligned in the left margin. A hanging indent is also known as the hanging paragraph.  

3 0
4 years ago
One of the most toxic components of a computer is the _____. one of the most toxic components of a computer is the _____. plasti
erik [133]
<span>One of the most toxic components of a computer is the </span>lead embedded in the glass of the monitor.  Lead is one the toxic chemicals that can harm us.
7 0
3 years ago
The computer program that Josh is working on presents him with a sentence in which a word has been underlined. Josh has to indic
Phantasy [73]

Answer:

Drill and Practice

Explanation:

<em>Drill and Practice</em> is a type of Computer-based Instruction (CBI) program. In <em>Drill and Practice</em>, answered questions are given immediate feedback. These problems or exercises are structured and answered on the program to provide instant feedback to the person taking the test.

<em>For instance</em>, when going through an evaluation test but you are required to provide the correct answer before moving on. Once a question is answered, the program will indicate whether correct or wrong, if the question is correct, move to the next question but if wrong you start again. This is a typical example of Drill and practice.

This is exactly what is seen in our scenario in the question.

4 0
3 years ago
JAVA
barxatty [35]

Answer:

Answer is in the provided screenshot! This was a lot of fun to make!

Explanation:

We need to create a new Array which has to be the size of amount * original - as we now that we are going to have that many elements. Then we just iterate through all the values of the new array and set them equal to each of the elements in order.

Ignore the code in my main function, this was to print to the terminal the working code - as you can see from the output at the bottom!

5 0
3 years ago
Other questions:
  • How have computers changed overtime
    13·2 answers
  • What is the maximum number of charters of symbols that can be represented by UNicode?
    5·1 answer
  • A user has requested a field that counts the number of child records associated with a custom object. These custom objects have
    5·1 answer
  • Judy forgot where she saved a certain file on her computer. Therefore, she searches for all files with a .jpg file extension. Wh
    7·2 answers
  • Which of these colors is most likely to be outside the CMYK gamut?
    15·1 answer
  • In what Career Cluster you get to design, build, and destroy things
    6·1 answer
  • Python uses standard order of operations to evaluate equations. True False
    5·1 answer
  • which option dexcribes a situation when asexual reproduction would be more advantageous to an organism?
    14·1 answer
  • How does a file reader know where one line starts and another ends?
    13·1 answer
  • suppose a network could gaurantee that all delivered packets were delivered in order. if a reliable transport protocol designer
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!