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]
3 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]3 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
Why do you think LinkedIn has become so popular?
mart [117]
Because it is a liable source for business.
6 0
3 years ago
Java can be procedural or object-oriented when it comes to programming. What is the difference between procedural and OOP?​
Helen [10]

Answer:

Procedural Programming => Functions

Object-Oriented Programming => Classes

Explanation:

Procedural programming is essentially what it sounds like – it's a series of procedures that the computer executes out. A procedure is essentially a function built of different steps that you the coder have grouped as such.

Object-Oriented Programming is all about objects. Objects contain data in the form of attributes, and functions in the form of methods. The most popular Object-Oriented Programming languages are class based, meaning that each object is an instance of a class (the class being a template).

Hope that helps! And you can always research more online!

7 0
3 years ago
5. Which of the following could occur making it necessary for Amy to troubleshoot her computer? Error messages keep popping up,
sleet_krkn [62]

Answer:

Adding new hardware/Software

Explanation:

Depending on how much you add to your computer it could make it have too much, so it can work slower and make it malfunction therefore i would Troubleshoot for that reason.

3 0
3 years ago
Which of these is not a combination of a keyboard and percussion musical instrument?
Sergio [31]

Answer:

The Harmonium is not a combination of a key board and percussion musical instrument.

Explanation:

The Harmonium is not a combination of a key board and percussion musical instrument.

A harmonium, also called a "melodeon", "reed organ" or "pump organ", is a keyboard instrument that is a lot like an organ. It makes sound by blowing air through reeds, which are tuned to different pitches to make musical notes.

3 0
2 years ago
If your computer is frozen what is something you would do to troubleshoot the problem ​
SpyIntel [72]

Answer:

Ctrl+Alt+Del

Explanation:

It will take you to the task manager and you can highlight the program that is frozen, right click on it and select end task. Or hard reboot as a last resort.

4 0
1 year ago
Other questions:
  • the task is to ask the user for three numbers and find the average which pseudocode gives you the comment outline for task​
    10·1 answer
  • A rectangular range of cells with headings to describe the cells' contents is referred to as a
    9·1 answer
  • Erick, who is taking an online course, sent an e-mail to his
    14·2 answers
  • What types of scientific claims should be verified
    5·1 answer
  • Explain the term remote backup with examples.​
    5·1 answer
  • A Windows application which demands a lot of raw processing power to execute repetitive complex calculations is a good candidate
    9·1 answer
  • You are the administrator of a Windows network. When creating a new user account, you specify a security clearance level of top
    8·1 answer
  • Jason Has A Science Video Project, As He Creats His Project, He Saves, Then Comes Back A Minute Later. The File Is Now Unreadabl
    8·2 answers
  • Help plz, u just gotta select all that apply :)
    15·1 answer
  • How to implement switch statement in Python?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!