Write a for loop that prints out the numbers 0 to 10 write


Assignment

Follow the instructions provided below.

1. Write a for loop that prints out the numbers 0 to 10.

2. Write a for loop that prints out the numbers 5 to 10.

3. Write a for loop that prints out the numbers -15 to -10.

4. Write a for loop that prints out the numbers -20 to -25 (Hint: Use three arguments).

5. Write a for loop that prints out ONLY the even numbers from 0 to 10 inclusive.

Use an IF statement and the mod (%) operator rather than changing the parameters of the range() function.

6. Ask the user to enter a value and store the result in a variable called n.

Use a for loop to calculate the factorial of n, or the product of all numbers from 1 to n.

Formula: n factorial = 1 * 2 * 3 * ... * (n - 1) * n

7. Write a *nested* for loop that produces the output shown in the Blackboard attachment.

Hint: What values do your indexes have to be?
Hint: Do you have to cast any values?

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Write a for loop that prints out the numbers 0 to 10 write
Reference No:- TGS02658062

Now Priced at $35 (50% Discount)

Recommended (90%)

Rated (4.3/5)