answersLogoWhite

0


Best Answer

This can be easily done using the modulo operation (represented by the '%' symbol). This operation gives the remainder of the division of the two numbers used in it.

e.g. 4 % 2 = 0, 5 % 2 = 1, 10 % 3 = 1, 10 % 2 = 0

In a modulo operation, any even number divided by 2 will always have a remainder of 0. Therefore, any number divided by 2 with a remainder of more than 0 must be odd. This can be done in Python for a number range like so:

current_number = 1 # variable to store the current number being checked

while current_number <= 10: # loop to go through the range of numbers up until 10

if current_number % 2 > 0: # check if the current number has a remainder of more than 0

print(current_number) # if it does, then print it out

current_number += 1 # move to the next number

This will print out all the odd numbers up until 10, each on a separate line.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you print 1-10 odd numbers in python?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

How many odd numbers are between 110 and 1000?

There are a total of 890 numbers between 110 and 1000 inclusive - 445 of these are odd, and 445 are even.


Write a C Program to print sum of squares of odd numbers?

#include


Program for check a number is even or odd using PYTHON language?

This program checks whether a number is odd or even. NOTE: This site removes formatting from answers. Replace (tab) with a tab or four spaces. #!/usr/bin/python print("Type a number.") n = input(": ") l = len(n)-1 even = ("02468") if n[l] in even: (tab)print(n, "is even.") if n[l] not in even: (tab)print(n, "is odd.")


Program in python to find whether given no is odd or even?

The best way to do this would be to use the "mod" function. It returns the remainder after performing integer division. For example, 9 mod 2 would be 1 because the remainder of 9/2 is 1. Mod is represented by %. With this in mind, all odd numbers mod 2 will equal 1, and all even numbers will equal 0. number = raw_input("Please enter an integer: "); if number % 2 == 1: print number + " is odd."; else: print number + " is even.";


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Display odd number using for loop?

It is actually quite easy to write a program in java to do this. The easiest way to do this that I can think of is to use the remainder operator (%) to test whether a number is odd or not. Here is a simple program that will print out all the odd numbers between 1 and 50. public class OddNumbers { public static void main(String[] args) { int i=1; while(i &lt; 50) { if(i%2 != 0) { System.out.println(i); } i++; } } }


How many odd prime numbers are there from 100-110?

Four. They are 101, 103, 107, and 109.Note:All prime numbers are odd, except '2'. All other even numbersare multiples of 2, so none of them can be primes.


Do all odd numbers have other odd numbers as their factors?

Yes, the factors of all odd numbers are odd numbers.


Is 110 even or odd number?

110 is an even number. This is true for any number that does not end in an odd number.


What snake is odd one out viper Cobra python rattlesnake?

Python. The others kill by biting and venom, whilst the Python kills by constriction.


Write a program to print even and odd numbers in between 1 to 10?

for (int i = 2; i < 10; i ++) printf("%d\n", i); You did say even and odd numbers between 1 and 10. That's allnumbers between 1 and 10.


Is sum of odd numbers always even?

The sum of two odd numbers is always even; the sum of three odd numbers is always odd; the sum of four odd numbers is always even; the sum of five odd numbers is always odd; etc