Answer:
string=""
while string not in {"Quit","quit","q"}:
string=input("Enter line to be reversed") #line of text will be entered
if string!="Quit" and string!="quit" and string!="q": #If quit is not entered
print("Reverse of line is : ")
print(string[::-1])
OUTPUT :
Enter line to be reversedThis code is in python language
Reverse of line is :
egaugnal nohtyp ni si edoc sihT
Enter line to be reversedHello world
Reverse of line is :
dlrow olleH
Enter line to be reversedquit
Explanation:In the above program, First a while loop is executed and checked if line of text is not 'quit', 'Quit' or 'q'. If condition is true, then loop is executed and in python any string or list can be traversed from end if step is given -1. Similarly line of text is accessed from the last element. If quit is entered, then the program will be broken out of the loop.
You can list the numbers . keep listing them till you find the same numbers
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:
A) Number of bits for byte = 6 bits
B) number of bits for index = 17 bits
C) number of bits for tag = 15 bits
Explanation:
Given data :
cache size = 64 kB
block size = 32 -byte
block address = 32 -bit
number of blocks in cache memory
cache size / block size = 64 kb / 32 b = 2^11 hence the number of blocks in cache memory = 11 bits = block offset
A) Number of bits for byte
= 6 bits
B) number of bits for index
block offset + byte number
= 11 + 6 = 17 bits
c ) number of bits for tag
= 32 - number of bits for index
= 32 - 17 = 15 bits