menu
bartleby
search
close search
Hit Return to see all results

Hi,please I need to use Python for the following:Use for loop to do the following:1) print the numbers 0 to 9 2) print first 10 odd numbers 3) print the numbers 20 down to 10 4) print even numbers from 20 down to 10 5) print even numbers from 20 down to 10 separated by ','

Question

Hi,please I need to use Python for the following:

Use for loop to do the following:

1) print the numbers 0 to 9

 

2) print first 10 odd numbers

 

3) print the numbers 20 down to 10

 

4) print even numbers from 20 down to 10

 


5) print even numbers from 20 down to 10 separated by ','

check_circleAnswer
Step 1

Program instructions:

  • Use range() in for loop to print the numbers.
  • Function range() has here arguments range(start, stop, step).
  • Use end in print() to print the numbers separated by “,”.
Step 2

Program:

#print the numbers 0 to 9

for i in range(10):

  print(i)

# print first 10 odd numbers

for i in range(1,20,2):

  print(i)

# print the numbers 20 down to 10

for i in range(20,9,-1):

  print(i)

# print even numbers from 20 down to 10

for i in range(20,9,-1):

  if i%2==0:

    print(i)

#  print even numbers from 20 down to 10 separated by ','

for i in range(20,9,-1):

  if i%2==0:

    print(i,end=",")

Step 3

Sample Output 1:

...
0
1
7
OH23" in wnoo
help_outline

Image Transcriptionclose

0 1 7 OH23" in wnoo

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: How would I write a C program to find the length of the longest substring of a given string without ...

A: The given program is to find the maximum length of the substring without repeating character. This i...

question_answer

Q: Write a program that contains 2 methods, main and printLine 1) The printLine method will do the foll...

A: Program plan: Import necessary packages.Define a class named “PrintCheck”.Define a method called “pr...

question_answer

Q: what is the most cheapest firewall

A: Firewalls provide security to the network by monitoring and controlling the network traffic. It crea...

question_answer

Q: Write a function that takes in three numbers as parameters and prints out the largest of the three. ...

A: Program to write a function that takes in three numbers as parameters and prints out the largest of ...

question_answer

Q: Assume the following declarations and initializations (MIN, MAX, num) are made just before each sub-...

A: Since these are separate blocks of code, for the purpose of demonstration we put the blocks in same ...

question_answer

Q: Consider a 32-bit hexadecimal number stored in memory as follows: Address Value 100 2A 101 ...

A: Big-endian:Big-endian is defined as the order in which the most significant value in the sequence is...

question_answer

Q: Use Eclipse for do this program. Show the output of the following statements.a) System.out.printf("a...

A: The program has the following algorithm:a) The statement print the amount in floating point and expo...

question_answer

Q: Develop pseudocode for the problem of reading in an arbitrary number of DNA (deoxyribonucleic acid) ...

A: PseudocodeCreate a dictionary data structure to store the DNA base and the complementary base as ser...

question_answer

Q: You are not required to execute the queries. However, your syntax must by accurate.You must give at ...

A: Answer for 11: SELECT MIN(MEM_BALANCE) AS MINIMUM_BALANCE, MAX(MEM_BALANCE) AS MAXIMUM_BALANCE, AVG(...

Sorry about that. What wasn’t helpful?