Answer:
i think the answer would be (B)
Explanation:
Answer:
The solution code is written in Python 3
- total = 0
- count = 0
- neg = 0
- pos = 0
-
- num = int(input("Enter an integer: "))
-
- while(num != 0):
- total += num
- count += 1
-
- if(num < 0):
- neg += 1
- else:
- pos += 1
-
- num = int(input("Enter an integer: "))
-
-
- print("The number of positives: " + str(pos))
- print("The number of negatives: " + str(neg))
- print("The total is " + str(total))
- print("The average is " + str(total/count))
Explanation:
Firstly, we create four variables, <em>total</em> , <em>count,</em> <em>neg</em> and <em>pos </em>(Line 1- 4). This is to prepare the variable to hold the value of summation of input integer (<em>total</em>), total number of input number (<em>count</em>), total negatives (<em>neg</em>) and total positives (<em>pos</em>).
Next, we prompt user for the first integer (Line 6).
Create a sentinel while loop and set the condition so long as the current input number, <em>num</em> is not equal to zero. the program will just keep adding the current <em>num</em> to total (Line 9) and increment the count by one (Line 10).
if <em>num</em> smaller than zero, increment the <em>neg</em> by one (Line 13) else increment the <em>pos </em>by one (Line 15). This is to track the total number of positives and negatives.
Finally, we can display all the required output (Line 20 - 23) using the Python built-in function <em>print()</em> when user enter 0 to terminate the while loop. The output shall be as follows:
The number of positives: 3
The number of negatives: 1
The total is 5
The average is 1.25
Answer:
Code in C++
Explanation:
C++ Code
#include<iostream> //for input and output
using namespace std;
int main()
{
int hour;
int minute;
cout<<"Enter the hour:";
cin>> hour;
cout<<"Enter the minute:";
cin>>minute;
minute = minute+15;
if(minute>=60){
hour++;
minute=minute-60;
}
if(hour>=24){
hour=0;
}
cout<<"Hours: "<<hour<<endl;
cout<<"Minutes:"<<minute;
return 0;
}
Code Explanation
First we need to declare two int variables to hold hour and minute values input from user.
Check if by adding 15 minutes into minute entered by user is greater then or equal to 60 then increment into hour and subtract 60 from minute.
Another check is that if user enters more then 24 hour or by making increment into hour, the hour values i greater then or equal to 24 then we need to change the hour to 0.
Result
Case 1:
Enter the hour:8
Enter the minute:15
Hours: 8
Minutes:30
Case 2:
Enter the hour:9
Enter the minute:46
Hours: 10
Minutes:1
Answer:
books.append({5:2})
Explanation:
got it right on edge 2020