Answer:
Answer:
def main():
num = int(input("Input a number to check for prime: "))
if num > 1:
for i in range(2,num):
if (num % i) == 0:
print("%d is not a prime number" % num)
break
else:
print("%d is a prime number" % num)
break
else:
print("%d is not a prime number" % num)
if __name__ == "__main__":
main()
Explanation:
Solution retrieved from programiz.com.
Note, this program uses the idea of the Sieve of Eratosthenes to validate the input number by using the modulo operator to determine primeness.
The program will output to the user if the number input is indeed prime or not.
Cheers.
Explanation:
Answer:
<u>Algorithm()
</u>
1. p = Enter the price of item A.
2. c = Enter the number of A’s purchased.
3. Now the price per item with tax is:
t= p+(p*6/100)
4. The total cost of c items:
ct= t * c.
5. Print ct.
In this algorithm, we are taking the price per item and counting it’s cost including tax. Then we are multiplying the price per item with tax with the number of items we purchase, to find the overall cost with tax.
You may calculate the overall cost without tax as (p*c). Then you can find the overall cost with tax as ((p*c)+(p*c*6/100)), as in both way, we will get the same result.
def computeGrade(float grade, str a){
a = "A" if a > 0.9 else a = "B" if a > 0.8 else "C"
return a;
}
print(a)
In my answer I am making an assumption that there is no runtime error, if there is then the error is “a run-time error”.
The answer is the program suffers from a Logic Error
Answer:
It's up to personal preference.
Explanation:
iPhone/Apple gives more compliments to security than Android.
Android has more friendly user GUI and dev tools.