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
daser333 [38]
3 years ago
12

Can someone please help me with this PYTHON problem! please answer with code! the only parts that you need to change have # YOUR

CODE HERE
Subset Product¶
This next one asks you to employ a common recursive pattern — that of computing all the subsets of a given set of things. In this problem, you are to determine whether or not an integer P>1P>1 can be compute as the product of any combination of a provided list of integers (where each factor f >0>0 can only be used once).
Examples:
given P=10P=10 , and the list [2, 3, 4, 5], we see that 2×5=102×5=10 , so the answer is yes
given P=81P=81 , and the list [2, 2, 3, 3, 4, 9], 3×3×9=813×3×9=81 , so the answer is yes
given P=100P=100 and the list [3, 4, 5, 8, 10], the answer is no
Complete the implementation of the recursive can_make_product, which returns True or False based on whether the argument p can be computed as the product of some subset of the list of integers vals.
In [ ]:
def can_make_product(p, vals):
# YOUR CODE HERE
raise NotImplementedError()
. . .
In [ ]:
# (5 points)
from unittest import TestCas
tc = TestCase()
tc.assertTrue(can_make_product(10, [2, 5]))
tc.assertTrue(can_make_product(10, [2, 3, 4, 5]))
tc.assertTrue(can_make_product(10, [3, 4, 2, 5]))
tc.assertTrue(can_make_product(10, [10]))
tc.assertTrue(can_make_product(81, [2, 2, 3, 3, 4, 9]))
tc.assertTrue(can_make_product(66402, [2, 4, 5, 12, 17, 25, 31, 63]))
tc.assertFalse(can_make_product(10, [2, 2, 2, 4]))
tc.assertFalse(can_make_product(243, [2, 2, 3, 3, 3, 4, 4, 4]))
tc.assertFalse(can_make_product(81, [2, 3, 5, 9, 11]))
tc.assertFalse(can_make_product(100, [3, 4, 5, 8, 10]))
tc.assertFalse(can_make_product(12369, [3, 4, 5, 8, 19, 20, 31]))
Computers and Technology
1 answer:
enot [183]3 years ago
5 0

Answer:

tc.asserttalse can make product

You might be interested in
Berat wants to compare images of what the streets of New York City looked like one hundred years ago to now. Which of the follow
Vesnalui [34]

Answer:

I think the answer would be D.

7 0
3 years ago
Read 2 more answers
What to do if you click on a phishing link on iphone
gregori [183]

Answer:

Nothing, just exit out of it

Explanation:

5 0
3 years ago
Read 2 more answers
Write a test program that creates two Rectangle objects—one with width 4 and height 40 and the other with width 3.5 and height 3
BARSIC [14]

Answer:

public class Rectangle {

   private double width;

   private double heigth;

   public Rectangle(double width, double heigth) {

       this.width = width;

       this.heigth = heigth;

   }

   public double getWidth() {

       return width;

   }

   public void setWidth(double width) {

       this.width = width;

   }

   public double getHeigth() {

       return heigth;

   }

   public void setHeigth(double heigth) {

       this.heigth = heigth;

   }

   public double perimeter(double width, double heigth){

       double peri = 2*(width+heigth);

       return peri;

   }

   public double area(double width, double heigth){

       double area = width*heigth;

       return  area;

   }

}

class RectangleTest{

   public static void main(String[] args) {

       //Creating two Rectangle objects

       Rectangle rectangle1 = new Rectangle(4,40);

       Rectangle rectangle2 = new Rectangle(3.5, 35.7);

       //Calling methods on the first Rectangel objects

       System.out.println("The Height of Rectangle 1 is: "+rectangle1.getHeigth());

       System.out.println("The Width of Rectangle 1 is: "+rectangle1.getWidth());

       System.out.println("The Perimeter of Rectangle 1 is: "+rectangle1.perimeter(4,40));

       System.out.println("The Area of Rectangle 1 is: "+rectangle1.area(4,40));

       // Second Rectangle object

       System.out.println("The Height of Rectangle 2 is: "+rectangle2.getHeigth());

       System.out.println("The Width of Rectangle 2 is: "+rectangle2.getWidth());

       System.out.println("The Perimeter of Rectangle 2 is: "+rectangle2.perimeter(4,40));

       System.out.println("The Area of Rectangle 2 is: "+rectangle2.area(4,40));

   }

}

Explanation:

  • Firstly A Rectangle class is created with two fields for width and heigth, a constructor and getters and setters the class also has methods for finding area and perimeters
  • Then a RectangleTest class containing a main method is created and two Rectangle objects are created (Follow teh comments in the code)
  • Methods to get height, width, area and perimeter are called on each rectangle object to print the appropriate value
5 0
3 years ago
Write a code snippet Now write your own code snippet that asks the user to enter two numbers of integer type (one at a time) and
taurus [48]

Explanation:

num1= print("Enter a number :")

num2 = print("Enter a number :")

sum = num1 + num2

print(sum)

4 0
2 years ago
What is the output of this code? import java.util.HashSet; class A { public static void main(String[ ] args) { HashSet set = new
kompoz [17]

Answer:

The code will give an error that is "At least one public class is required in main file".

Explanation:

In the given code if we do not use the public access modifier to the class. It will give an error so, the correct code to this question as follows:

Program:

import java.util.HashSet; //import package

public class A  //define class as public.

{

   public static void main(String[ ] args) //define main method.

   {

       HashSet set = new HashSet(); //creating hashset object.

       set.add("A"); //add alphabet in hashset

       set.add("B"); //add alphabet in hashset

       set.add("C"); //add alphabet in hashset

       System.out.print("Size of HashSet is :"set.size()); //print the size of hashset.

   }

}

Output:

Size of HashSet is : 3

Explanation of the program:  

  • In the above program, we define a public class that is "A" and inside the class, we define the main method.  
  • Inside the main method, we create a HashSet class object that is "set".  
  • To add elements in HashSet we use add() function that adds elements and in the last, we use the size() function that prints the size HashSet.
5 0
3 years ago
Other questions:
  • A peripheral can be used to tell a computer to complete a specific task. True False
    15·1 answer
  • Which of the following is an important initial step in designing an interface
    7·1 answer
  • In what year did commercial use of the Internet become available? 1991 1996 1999 2001
    9·1 answer
  • What do you call a named collection of data stored on a disk?
    15·1 answer
  • What is a 'balanced' dfd?
    5·1 answer
  • A _____ is a harmful program that resides in the active memory of a computer and duplicates itself. Select one: a. scareware b.
    7·1 answer
  • IOS jail broken or Android unrooted which is better to hack with
    6·1 answer
  • Which of these causes the most collisions?
    14·1 answer
  • The force required to slide an object is equal to _____.
    13·1 answer
  • Using the Insert tab, you can convert text into a table and a table into text.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!