Following are the python program to use the loop to count the number of pets until the user enters the "rock":
c = 0#defining a variable c that initilzes with 0
p = input()#defining a variable p that input value
while p != 'rock':#defining a loop that check p value not equal to rock
c += 1#using c variable for counts total number of pets
print('You have a %s with a total of %d pet(s)' %(p,c))#print total number of pet
p = input() #input value
Output:
Please find the attached file.
Program Explanation:
Find out more about the loop here:
void f1(int array, int size);
void f1(int& array, int size);
void f1(int array[100], int size);
void f1(float array[], int size);
All of the above
C and D
A and B
Answer:
Only
Option: void f1(float array[], int size);
is valid.
Explanation:
To pass an array as argument in a function, the syntax should be as follows:
functionName (type arrayName[ ] )
We can't place the size of the array inside the array bracket (arrayName[100]) as this will give a syntax error. The empty bracket [] is required to tell the program that the value that passed as the argument is an array and differentiate it from other type of value.
Answer:
Must use mutators to initialize class data.
May use assignment statements to initialize class data.
Explanation:
These are the two characteristics that are present in constructors. A constructor is an instance method of a class or structure that creates an object of the class to which it belongs. This is mostly used in object-oriented programming. These constructors usually have the same name as the actual class, and can be used in order to set the values of the members of an object.
2... 10 Card values
J Jack
Q Queen
K King
D Diamonds
H Hearts
S Spades
C Clubs
Your program should print the full description of the card. For example, Enter the card notation: QS Queen of Spades
Implement a class Card whose constructor takes the card notation string and whose getDescription method returns a description of the card. If the notation string is not in the correct format, the getDescription method should return the string "Unknown".
Answer:
In python Language:
cardNotation = raw_input("Enter card notation: ")
# Create a dict for values
cardColors = {"D": "Diamonds",
"H": "Hearts",
"S": "Spades",
"C": "Clubs"}
cardNumberValues = {"A": "Ace",
"J": "Jack",
"Q": "Queen",
"K": "King",
"2": "Two",
"3": "Three",
"4": "Four",
"5": "Five",
"6": "Six",
"7": "Seven",
"8": "Eight",
"9": "Nine",
"10": "Ten"}
# Handle cases when 10 comes in input
if len(cardNotation) == 3:
number = cardNotation[:2]
color = cardNotation[2:]
print cardNumberValues.get(number) + " of " + cardColors.get(color)
elif len(cardNotation) == 2:
number = cardNotation[:1]
color = cardNotation[1:]
print cardNumberValues.get(number) + " of " + cardColors.get(color)
else:
print "INVALID VALUE"
Answer:
The formula in Excel is:
=($B$6 - $B$5 - $B$7)* $B$8
Explanation:
Required
Use of absolute reference
To reference a cell using absolute reference, we have to include that $ sign. i.e. cell B5 will be written as: $B$5; B6 as $B$6; B7 as $B$7; and B8 as $B$8;
Having explained that, the formula in cell B13 is:
=($B$6 - $B$5 - $B$7)* $B$8
Answer:
To edit an existing pattern, double-click the pattern in the pattern swatch, or select an object containing the pattern and choose Object > Pattern > Edit Pattern