A program that repeatedly prompts a user for integer numbers :
biggest = none
smallest = none
while True:
input = raw_input(“Enter a number:”)
if(input == “done” break
try:
number = float(inp)
except ValueError:
print “Please enter only numbers”
else
if smallest is None:
smallest = number;
biggest = number;
elif number < smallest:
smallest = number
elif num > largest:
largest = number
Print “Greatest is “, biggest
Print “Smallest is”, smallest
In this program an input is obtained, if it is equal to the word “done”, then the program stops b printing greatest and smallest number in the given input.
If invalid inputs are given then user is prompted to enter valid number. Otherwise the value of smallest and greatest are calculated according to the input using if-else construct.
Answer:
<em>C++.</em>
#include <iostream>
using namespace std;
////////////////////////////////////////////////////////////////
int main() {
int weekly_hours = 0;
int hourly_rate;
float gross_pay = 0;
cout<<"Enter weekly hours worked: ";
cin>>weekly_hours;
cout<<"Enter hourly rate: ";
cin>>hourly_rate;
cout<<endl;
////////////////////////////////////////////////
if (weekly_hours > 40) {
gross_pay = (weekly_hours*hourly_rate) + ((weekly_hours*hourly_rate)*0.5);
}
else
gross_pay = weekly_hours*hourly_rate;
cout<<"Weekly gross pay: $"<<gross_pay;
////////////////////////////////////////////////
return 0;
}
Answer:
A) work study program
Explanation:
Because you need experience and scholarships don't always pay, so this is the best choice.
Answer:
if full_admission_price = f and discount_amount = d
=> Price of a discount admission = d/f
total_weight
quantity
weight of one item = total_weight/quantity
for i in range(80, 18, -2):
print(i, end=' ')
Explanation:
The first two questions are just mathematical to get a single quantity given some relationship. So, its basically division
For the python code, I used the python's range function which takes in three arguments. The first one is the starting value, the second one is the terminating value which is the number before the terminating value and the last one specifies the common difference popularly known as step in the language. Since the step is 2, only even numbers are printed out. In the print function, I made use of the end keyword specifying a space (' ') as the end. This ensures that the print is done in the same line with a space seperating them. Without that specification, each result will printed in a newline