Because this is a on your own problem, it cannot be solved. You must speak to it after the person says something.
Answer:
Explanation:
The following program is written in Java. Using the program code from Purchase class in 5.13 I created each one of the fruit objects. Then I set the price for each object using the setPrice method. Then I set the number of each fruit that I intended on buying with the setNumberBought method. Finally, I called each objects getTotalCost method to get the final price of each object which was all added to the totalCost instance variable. This instance variable was printed as the total cost of the bill at the end of the program. My code HIGHLIGHTED BELOW
//Entire code is in text file attached below.
//MY CODE HERE
DecimalFormat df = new DecimalFormat("0.00");
oranges.setPrice(10, 2.99);
oranges.setNumberBought(2*12);
eggs.setPrice(12, 1.69);
eggs.setNumberBought(2*12);
apples.setPrice(3, 1);
apples.setNumberBought(20);
watermelons.setPrice(1, 4.39);
watermelons.setNumberBought(2);
bagels.setPrice(6, 3.50);
bagels.setNumberBought(12);
totalCost = oranges.getTotalCost() + eggs.getTotalCost() + apples.getTotalCost() + watermelons.getTotalCost() + bagels.getTotalCost();
System.out.println("Total Cost: $" + df.format(totalCost));
}
}
Answer:
1) # function to print volume of a sphere
def print_volume(radius):
volume= (4/3)*3.14*radius*radius*radius
print("Volume:{0}",volume)
print_volume(4.23)
print_volume(4.34)
print_volume(12.34)
Output:
Volume:{0} 316.8761018400001
Volume:{0} 342.24536341333334
Volume:{0} 7867.085384746666
2) # area of square calculator
def print_area(length):
area=length*length
print("Area of Square{0}",area)
print_area(4.23)
print_area(4.34)
print_area(12.34)
Output:
Area of Square{0} 17.892900000000004
Area of Square{0} 18.8356
Area of Square{0} 152.2756
Explanation:
We have created two functions, first to calculate the volume of a sphere. and second to calculate the area of a square. Remember pi=3.14.
I think the best answer is D. Initialize the loop control variable prior to entering the loop body.
Please correct me if I'm wrong!! I'd be happy to fix it!! :)
Answer:
couple.py
def couple(s1,s2):
newlist = []
for i in range(len(s1)):
newlist.append([s1[i],s2[i]])
return newlist
s1=[1,2,3]
s2=[4,5,6]
print(couple(s1,s2))
enum.py
def couple(s1,s2):
newlist = []
for i in range(len(s1)):
newlist.append([s1[i],s2[i]])
return newlist
def enumerate(s,start=0):
number_Array=[ i for i in range(start,start+len(s))]
return couple(number_Array,s)
s=[6,1,'a']
print(enumerate(s))
print(enumerate('five',5))
Explanation: