Answer:
if(revenue.cents - expenses.cents < 0){
profit.dollars = revenue.dollars - expenses.dollars - 1;
profit.cents = 1 - revenue.cents - expenses.cents;
}
else{
profit.dollars = revenue.dollars - expenses.dollars;
profit.cents = revenue.cents - expenses.cents;
}
Explanation:
We know that profit is given as: revenue - expenses from the question.
From the given expression above;
if(revenue.cents - expenses.cents < 0)
then profit.dollar will be revenue.dollars - expenses.dollars - 1; the 1 is to be carry over to the cent part. And the profit.cent will be 1 - revenue.cents - expenses.cents;
else the profit.dollars and the profit.cent is computed directly without needing to carry over:
profit.dollars = revenue.dollars - expenses.dollars;
profit.cents = revenue.cents - expenses.cents;
Answer:
Following are the expression to this question:
if (young and famous==True):
Explanation:
For print, the given expression the code requires some modification that can be defined as follows:
young = True#defining a bool variable that holds a value True
famous = True#defining a bool variable that holds a value True
if (young and famous==True):#defining if block that check variable value
print('You must be rich!')#print message
else:#else block
print('There is always the lottery...')#print message
Output:
You must be rich!
Code explanation:
In the above-given code, two variable "young and famous" is declared, that hold a "True" which is a bool value, in this code, a conditional statement has used, that checks variable value, which can be defined as follows:
- In the if block, it uses the above declared variable with and gate to check its value is equal to true.
- If the condition is true, it will print the true block message, otherwise, go to the else block in this, it will print the else block message.
They are versatile because they can be used for all sorts of tasks. They can also do many of the same tasks in different ways. They are diligent because they will do a task thoroughly until it is finished.
They work at a constant speed to do the task. Unlike a human, they will not slow down or get bored or start making mistakes that they were not doing earlier. So once they are programmed correctly to do a task, they will do it diligently.
Show the picture to answer the question