Write a recursive method called, doMyMath, which takes as input any positive integer and calculates the factorial (use comments for necessary items).

Answers

Answer 1

Answer:

def doMyMath(n):  

    if n == 1:  

         return n  

    else:  

         return n*doMyMath(n-1)  

Explanation:

This line defines the function

def doMyMath(n):  

This line checks if n is 1. If yes, it returns n (1)

    if n == 1:  

         return n  

If otherwise, it calculates the fibonacci recursively

    else:  

         return n*doMyMath(n-1)  

To call the function from main, you can use:

print(doMyMath(5))

or

num = int(input("Number: "))   --- This gets the number from user

print("Result: ",doMyMath(num)) --- This calculates the factorial

This question is answered in Python


Related Questions

If an object someThing has a method someMethod( ), then you can call the method using the statement ____________ .
a. someMethod(someThing);
b. someThing.someMethod( );
c. someMethod.someThing() ;
d. someThing = someMethod( );

Answers

Answer:

C) someThing.someMethod( )

Explanation:

The methods in a class can be accessed outside the class (assuming they are public methods and not private to the class) by using the dot(.) symbol and calling the method on the instance or object of the class.

In this case, the object of the class someThing, calls the method, someMethod( ) by using a dot and the name of the method with a parentheses at the end. This enables the code in the method act on the class instance or object.

Problem 4 (25 points)Consider a byte addressing architecture with 64-bit memory addresses.(a)Which bits of the address would be used in the tag, index and offset in a direct-mapped cache with 512 1-word blocks. 3(b)Which bits of the address would be used in the tag, index and offset in a direct-mapped cache with 64 8-word blocks.(c)What is the ratio of bits used for storing data to total bits stored in the cache in each of the above cases

Answers

Answer:

Following are the solution to the given points:

Explanation:

The Memory address value = 64 bit

The Size of the word [tex]= \frac{64}{8} =8 \ Byte[/tex]

In point a:

The offset size [tex]= 3\ bits[/tex] ( in 1-word block size)  

The Index size [tex]= 9 \ bits[/tex] (as block number =512)  

Tag size [tex]= 64 - 12 = 52\ bits[/tex]

In point b:

The offset size [tex]= 8 \times 8 \ bytes = 2^6 = 6 \ bits.[/tex]

The Index size [tex]= 64 \ bits = 2^6 \ =6 \ bits[/tex]

Tag size  [tex]= 64 - 12 = 52\ bits[/tex]

In point c:

The Ratio at point a  

[tex]\to 3:64[/tex]

The Ratio at point b

[tex]\to 6:64[/tex]

Why are people's visions of utopias and dystopias subjective?
A. Because the vision one person has of paradise will likely match
the vision most people have of a utopia
B. Because only certain technologies make things better and
different ones make things worse in a dystopia
C. Because all technology is dangerous and can lead to the downfall
of all societies, resulting in dystopia
D. Because the technology needed for one person's utopia may be
what creates disaster for another person's dystopia

Answers

Answer:

D. Because the technology needed for one person's utopia may be what creates disaster for another person's dystopia.

Explanation:

Because the technology needed for one person's utopia may be what creates disaster for another person's dystopia are people's visions of utopias and dystopias subjective. Thus option D is correct.

What are utopias and dystopias?

Speculative fiction categories that study social as well as political structures include utopian and dystopian literature. In order to pique readers' interest, utopian fiction often depicts a world that adheres to the author's ethics and has many elements of a different reality.

Ultimately, it all varies depending on who you ask. A person's dystopia may be another person's utopia. We don't all have the same notions regarding what a utopia would look like, which is, in my opinion, one of the grounds why people don't live in one. Therefore, option D is the correct option.

Learn more about utopias and dystopias, Here:

https://brainly.com/question/905235

#SPJ2

Which interpersonal skill is the most important for a telecom technician to develop?
teamwork
active listening
conflict resolution
social awareness

Answers

Answer: Interpersonal communication is the process of face-to-face exchange of thoughts, ideas, feelings and emotions between two or more people. This includes both verbal and nonverbal elements of personal interaction.

Explanation:

i think plz dont be mad

C++ please
Write a program that does the following.
Create a dynamic two dimensional squarearray of unsigned integers (array_one). Prompt the user to enter the number of rows and columns they want (maximum of 30) (rows and columns must be the same for a square array)
Pass the array to a function that will initialize the two dimensional array to random numbers between 0 and 4000 using the rand() library function. Here is the kicker: The array cannot have any repeated values!
Create another dynamic two dimensional array of the same size (array_transpose)
Pass both arrays to a function that will generate the transpose of array_one returning the values in array_transpose. (If you don’t already know the transpose swaps the rows and columns of an array.) Example: Suppose you have a 4 x 4 array of numbers (array_one). The transpose is shown below (array_transpose)
Array One Array Transpose
1 2 3 4 1 5 9 13
5 6 7 8 2 6 10 14
9 10 11 12 3 7 11 15
13 14 15 16 4 8 12 16
Pass each array to a print_array function that will print (to the screen or a file) the results of a test case with a 20 by 20 array.

Answers

Answer:

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int main(){

   int n;

   cout<< "Enter the row and column length: ";

   cin>> n;

   int array_one[n][n];

   int array_transpose[n][n];

   for (int i = 0; i < n; i++){

      for (int j= 0; j < n; j++){

           srand((unsigned) time(0));

           array_one[i][j] = (rand() % 4000)

           array_transpose[j][i] = array_one[i][j];

       }

   }

}

Explanation:

The C source code has three variables, 'array_one', array_transpose' (both of which are square 2-dimensional arrays), and 'n' which is the row and column length.

The program loops n time for each nth number of the n size to assign value to the two-dimensional array_one. the assign values to the array_transpose, reverse the 'i' and 'j' values to the two for statements for array_one to 'j' and 'i'.

Even with a quality burglary-resistant chest on the premises, special function locks may be appropriate because:________.
a. A dishonest worker might open the safe at night .b. A burglar may force a worker to open the safe during working hours.c. Without special locking devices, workers may be tempted to leave the safe unlocked for easy access during the day.d. All of the above

Answers

Answer:

d ) all of the above

Explanation:

is the correct answer

The question is in the photo

Answers

Answer:

a

the most suitable answer

8. Write the examples of freeware and Shareware softwares ?

Answers

Explanation:

People use freeware software because it is available free of cost and it can be distributed free of cost, that is why it is called FREEware.

Freeware software:

Adobe PDF

yahoo messenger

Go.ogle Talk

MSN messenger

People use shareware software because it helps them to know about the product more before buying it and this software is available free of cost.

Shareware software:

Adobe acrobat 8 professional

Winzip

Getright

Is anyone else having an issue with brainly mobile, where they don't let you watch ads? If so, what do you do to fix it?​

Answers

Answer:

no im not

Explanation:

but i sorry that you are

Use the drop-down tool to select the phrase that completes each sentence,
In Windows, deleted files go to the
If you want to see the most information about a file, you can view them in
A file manager can help you
DONE
I

Answers

Answer:

1. recycle bin

2. details view

3. move a file

Explanation:

i did the assignment on edge. and got it right

Answer:

In Windows, deleted files go to the

✔ Recycle Bin

If you want to see the most information about a file, you can view them in

✔ details view

A file manager can help you

✔ move a file

Explanation: Hope it helps ^w^

The National Vulnerability Database (NVD) is responsible for actively performing vulnerability testing for every company's software and hardware infrastructure. Is this statement true or false?A. TrueB. False

Answers

Answer:

False

Explanation:

The answer to this question is false. This is because the NVD doesn't perform such tests on their own. Instead they they rely on third-party vendors, software researchers, etc to get such reports and do the assignment of CVSS scores for softwares

The National Vulnerability Database (NVD) is the United State governments leading resource for software vulnerability

Suppose that a t-shirt comes in five sizes: S, M, L, XL, XXL. Each size comes in four colors. How many possible t-shirts are there?

Answers

Answer:

120

Explanation:

This question is basically asking how many ways can we arrange 5 sizes of shirts if they come in 4 colors.

5 permutation of 4

To find permutation, we use the formula

P(n, r) = n! / (n - r)!

Where

n is the size of the shirts available, 5

r is the color of each shirt available, 4

P(5, 4) = 5! / (5 - 4)!

P(5, 4) = (5 * 4 * 3 * 2 * 1) / 1!

P(5, 4) = 120 / 1

P(5, 4) = 120

Therefore, the total number of shirts available is 120

If a computer reboots itself on its own, the computer might have a(n) access problem. hardware problem. Internet problem. software problem.

Answers

Answer:

D) Software problem

Explanation:

plz give me brainliest

D

edge2021      YWWWWWWWWWWWWWWWWWWWWW                                  

I really need help with coderZ does anyone kno?

Answers

Answer:

Easy-to-use virtual robotics and STEM platform tailored to serve every student at every level!

CoderZ is a powerful, award-winning online platform.

Explanation:

CoderZ is a powerful, award-winning online platform through which students learn valuable STEM skills such as coding, robotics, and physical computing. CoderZ is highly flexible and designed for use in the classroom or through a wide range of remote learning environments.  Computers and technology are everywhere. Studying science, technology, engineering and math gives kids valuable skills for the future and develop life-skills like computational thinking, critical thinking and problem-solving as well.

STEM and CS education focuses on how to approach complex problems, break down the challenges into small pieces and approach resolving them in a logical manner – critical skills for any career path.

You are part of a sales group that has been asked to give a presentation.
Before you begin, what should you and your group do?
O A. Figure out who is the best public speaker.
O B. Look into file-sharing options so that everyone can work on the
same file at the same time.
OC. Buy the best software on the market.
O D. Ask if you have to give a slide presentation.

Answers

The answer is the 2 one becuase I took the test

Columns, margins and orientation can all be found on what tab

Answers

Answer:

The right answer is: Option C: Layout.

Explanation:

Columns are used to write text in a word document in more than one columns. Similarly, margins is the empty space that is left blank from all sides of the page. Orientation can be either landscape or portrait.

all these options are found in the Layout tab in MS word.

Hence,

The right answer is: Option C: Layout.

What is the purpose of a Hyperlink

Can you answer both

Answers

Answer:

Number 16 is A Or B And Number 17 is B I think

Explanation:

A strictly dominates choice B in a multi-attribute utility. It is in your best interest to choose A no matter which attribute youare optimizing.

a. True
b. False

Answers

Answer:

A strictly dominates choice B in a multi-attribute utility. It is in your best interest to choose A no matter which attribute youare optimizing.

a. True

Explanation:

Yes.  It is in the best interest to choose option A which dominates choice B.  A Multiple Attribute Utility involves evaluating the values of alternatives in order to make preference decisions over the available alternatives.  Multiple Attribute Utility decisions are basically characterized by multiple and conflicting attributes.  To solve the decision problem, weights are assigned to each attribute.  These weights are then used to determine the option that should be prioritized.

Write a program that asks the user for a word. Next, open up the movie reviews.txt file and examine every review one at a time. If a review contains the desired word you should make a note of the review score in an accumulator variable. Finally, produce some output that tells your user how that word was used across all reviews as well as the classification for this word (any score of 2.0 or higher can be considered

Answers

Answer:

import numpy as np

word = input("Enter a word: ")

acc = []

with open("Downloads/record-collection.txt", "r") as file:

   lines = file.readlines()

   for line in lines:

       if word in line:

           line = line.strip()

           acc.append(int(line[0]))

   if np.mean(acc) >= 2:

       print(f"The word {word} is a positive word")

       print(f"{word} appeared {len(acc)} times")

       print(f"the review of the word {word} is {round(np.mean(acc), 2)}")

   else:

       print(f"the word {word} is a negative word with review\

{round(np.mean(acc), 2)}")

Explanation:

The python program gets the text from the review file, using the user input word to get the definition of reviews based on the word, whether positive or negative.

The program uses the 'with' keyword to open the file and created the acc variable to hold the reviews gotten. The mean of the acc is calculated with the numpy mean method and if the mean is equal to or greater than 2 it is a positive word, else negative.

In java
Write a program that draws out a path based on the user input. The starting coordinates for the path is the middle of the DrawingPanel. Ask the user to enter an x and a y coordinate for a DrawingPanel. Your program will draw a line from the last coordinates to the current coordinates the user enters. If the user enters an x value or y value out of bounds of the DrawingPanel, then end the program.

Answers

Answer:

import javax.swing.JPanel;

import javax.swing.JOptionPane;

import javax.swing.JFrame;

import javax.swing.JLabel;  

import javax.swing.JTextField;

import javax.swing.border.Border;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.BorderFactory;

import javax.swing.JButton;

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.FlowLayout;

import java.awt.Graphics;

import java.awt.Rectangle;

public class DrawingPanel{

 

private static final int width = 800;

private static final int heigth = 500;

private static JFrame mainFrame;

private static JPanel mainPanel, inputPanel, drawPanel;

private static JLabel xLabel, yLabel;

private static JTextField xField, yField;

private static JButton drawButton;

 

public static void main(String[] args)

{

mainFrame = new JFrame("Draw Path");

mainPanel = new JPanel(new BorderLayout());

 

inputPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

xLabel = new JLabel("X Coordinate: ");

xField = new JTextField(5);

yLabel = new JLabel("Y Coordinate: ");

yField = new JTextField(5);

drawButton = new JButton("Draw");

inputPanel.add(xLabel);

inputPanel.add(xField);

inputPanel.add(yLabel);

inputPanel.add(yField);

inputPanel.add(drawButton);

 

Border border = BorderFactory.createLineBorder(Color.black);

drawPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

drawPanel.setBorder(border);

 

mainPanel.add(inputPanel, BorderLayout.NORTH);

mainPanel.add(drawPanel, BorderLayout.CENTER);

 

mainFrame.add(mainPanel);

mainFrame.setSize(PANEL_WIDTH, PANEL_HEIGHT);

mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

mainFrame.setLocationRelativeTo(null);

mainFrame.setResizable(false);

mainFrame.setVisible(true);

 

// action listener for draw button

drawButton.addActionListener(new ActionListener() {

(use the at sign here)Override

public void actionPerformed(ActionEvent e) {

if(xField.getText().equals("") || yField.getText().equals(""))

JOptionPane.showMessageDialog(null, "Please enter the x and y coordinates!");

else

{

int x2 = Integer.parseInt(xField.getText().trim());

int y2 = Integer.parseInt(yField.getText().trim());

if(x2 > WIDTH || y2 > HEIGHT)

JOptionPane.showMessageDialog(null, "x and y coordinates should be less than "

+ width + " and " + height + " respectively!");

else

drawPath(x2, y2);

}

}

});

}

 

public static void drawPath(int x2, int y2)

{

int x1 = (int)drawPanel.getBounds().getCenterX();

int y1 = (int)drawPanel.getBounds().getCenterY();

 

Graphics g = drawPanel.getGraphics();

Rectangle r = drawPanel.getBounds();

g.setColor(drawPanel.getBackground());

g.fillRect(r.x, r.y, r.width, r.height);

 

g.setColor(Color. blue);

g.drawLine(x1, y1, x2, y2);

}

}

Explanation:

The class DrawingPanel is a Java class that gets the user input for the coordinate of a path with predetermined heigth and width (defined in the class). The methods of the class are; getGraphics(), getBounds(), getBackground(), setColor() and fillRect(). The result is a rectangular path GUI on the screen.

What is Microsoft PowerPoint?
Oa presentation program included with Microsoft Office
oa project management program available only in certain versions of Microsoft Office
Oa desktop publishing program included with Microsoft Office
oa collaboration program available only in certain versions of Microsoft Office

Answers

Answer:

ITS THE FIRST ONE :)

Explanation:

ALSO IF ITS NOT THE FIRST ONE GO ON YT!

Thale cress is a plant that is genetically engineered with genes that break down toxic materials. Which type of organism is described?
recombinant
transgenic
transverse
restriction

Answers

Answer: Transgenic

Explanation:

Since the thale cress is a plant that is genetically engineered with genes that break down toxic materials, the type of organism that is described here is the transgenic plant.

Transgene is when a gene is naturally transferred or transferred from an organism to another organism by genetic engineering method.

Therefore, the correct option is transgenic.

Answer:

The answer is B (transgenic)

Explanation:

2. The Warren Commission investigated the assassination of President _______________________ in 1964.

Answers

Answer:

President Kennedy

Explanation:

John F. Kennedy was the 35th President of US. He was assassinated in 1963 in Dallas

How do you overload a C2677 error code in c++ for '-'?

Answers

The answer is the c++ one I know becuase I took the test

Guys, please help me asap (Photo Attached) !!!!!!! HELP 25pts!!!!

Answers

The answer is the first number line.

30/150 = 1/5 = 20%

Answer:

20%

Convert fraction (ratio) 30 / 150 Answer: 20%

The first one.

Please I need one more braniest for 'expert' may I get it?

Explanation:

What input is needed for the defined output?

Answers

Answer:

The data that are needed to be included in the output is called as

Inputs are the signals or data received by the system and outputs are the signals or data sent from it. The term can also be used as part of an action; to "perform I/O" is to perform an input or output operation

Which of the following are downlink transport channels?
a. BCH.
b. PCH.
C. RACH.
d. UL-SCH.
e. DL-SCH.

Answers

I think it’s a or b

Question # 6
Dropdown
Choose the correct ending to the sentence below.


The function localtime() _____________________

Answers

Answer:

returns a different value every time you use it

Explanation: :)

Designing the right elements for the tasks that the user is attempting to perform is called ________.

Answers

Answer:

Interface design

Explanation:

INTERFACE DESIGN are design that are carried out on either a computer or a mobile phone or other devices that will suit the users by designing the style of the devices and how the device will look like which will inturn enable the user to easily carried out or performed any tasks they are want to perform with easy and without any lapses which is why it is important for INTERFACE DESIGN to be design with the right tools that the user can easily understand in order to access and perform their tasks effectively.

Which Cisco IOS command will permit the engineer to modify the current configuration of the switch while it is powered on?

Answers

Configure terminal because Commands in this mode are written to the running configuration file as soon as you enter them (using the Enter key/Carriage Return). After you enter the configure terminal command, the system prompt changes from switch# to switch(config)#, indicating that the switch is in configuration mode.
Other Questions
Should video gaming be considered a school sport? Read the Economy sections of these articles about Chile and Bolivia and compare the gross domestic product (GDP) data for the two countries. How does this economic data reflect each country's access, or lack of access, to the Pacific Ocean? Find the missing part. I = 8, w = 4, h = 2Find the diagonal (d) of the base.Click and look at the picture fully fill in the purple box the idea of separation of power was first suggested by which enlightenment thinker.(Group of answer choices)A: LockeB: HobbesC. MontesquieuD: Rousseau What is the name and artist of this picture? :) :) :):):):)):):):)):)/):))::)):):):):):)):):)):):))/):):)) Under the modified accrual basis of accounting for a governmental unit, revenues should be recognized in the accounting period in which they:____.A. Are earned and become measurable.B. Are collected Become available and measureable.C. Become available and earned.D. Are earned and collected. If a line goes through the following two points: (0,0) and (2,1), the slope of the line is:A. 3B. -2 C. 1/2D. -1/2 Stans Skate Shop is having a sale on skateboards. The original price for its Extreme Skateboard was $84.50. The sale price for the skateboard is $50.70. What is the percent decrease in the price of the skate board? Which of the following did Carter do in his attempt to free the Americans taken hostage by Iran? find UT.- 42.5- 16.25- 21.25- 32.5 The ratio of Dobermans to terriers is 2:7. There are 774 dogs altogether. How many Doberman is there?How many terriers? Which step(s) would create equations so that the coefficients of one of the variables areopposites?(A) Multiply the first equation by 7.Multiply the second equation by 3.(B) Multiply the first equation by -2.Multiply the second equation by 4.(C) Multiply the first equation by 2.(D) Multiply the second equation by 4. The Distributive PropertyPLZ HELP I WILL GIVE BRAINLIEST!!PLZ EXPLAIN I was born with water on the brain A. First person B. Second personC. Third person At Royston's favorite clothing store, the cost of a pair of jeans is $4 more than twice the cost of a shirt. The cost of a pair of dress pants is $2 less than 2.5 times the cost of a shirt. If the cost of a shirt is s dollars and Royston purchased 1 pair of jeans and 1 pair of dress pants, which expression represents the total amount he spent in terms of s? * If he ........... early, I'll leave late.2 can someone please help me . will mark you brainliest ! What is the length of the line segment with endpoints (-1, -2) and (4, 10)? Question 3 o 20Which of the following expressions would you hear at a fun party?O A. Vmonos!B. sta es una fiesta estupenda!C. Vamos a quedar en el hospital, no?D. Hay muchos aguafiestas aqu, no?