Question

Write a statement which assigns all the odd integer values between 0 and 10 (in order)...

Write a statement which assigns all the odd integer values between 0 and 10 (in order) to the variable named odds. Python Language

Homework Answers

Answer #1

1.Simple way--

odds=[1,3,5,7,9]

The screenshot of this statement and output is given below.




2.Using loop

odds=[]
for i in range(0,10):
if(i%2!=0):
odds.append(i)
  
print(odds)



The screenshot of the code and output is given below.








If the answer helped please upvote it means a lot. For any query please comment.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. Write a statement that assigns an empty list to the variable named empty. 2. Write...
1. Write a statement that assigns an empty list to the variable named empty. 2. Write a statement which assigns all the odd integer values between 0 and 10 (in order) to the variable named odds. 3. Write a statement which assigns the list of three-letter abbreviations of the months of the year to the variable months. That would be: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Capitalize correctly and have no punctuation. 4. Create...
Write a program to input a sequence of 8 integers, count all the odd numbers and...
Write a program to input a sequence of 8 integers, count all the odd numbers and sum all the negative integers. One integer is input and processed each time around the loop. Python Programming
1.) In order to have a loop that adds odd values from 10 through 20, what...
1.) In order to have a loop that adds odd values from 10 through 20, what would be entered in the blanks below: int oddAccumulator = 0; for (int i = [a]; i < [b]; i++) { if ((i % 2) != 0) { oddAccumulator += [c]; } } WriteLine("The sum of odd integers in the range of 10 - 20 is: {0} ", oddAccumulator); *I've figured out the answer for [a] = 10, [b] = 20, but I can't...
Challenge 1 - SumDigits.java Write a program that reads an integer between 0 and 1000 and...
Challenge 1 - SumDigits.java Write a program that reads an integer between 0 and 1000 and adds all the digits in the integer. For example, if an integer is 837, the sum of all digits is 18. Sample output: Enter an integer between 0 and 1000: 837 The sum of all digits in 837 is 18
If and else statements: 1a.) Given the following declaration: int temperature; Write an if statement that...
If and else statements: 1a.) Given the following declaration: int temperature; Write an if statement that prints the message "The number is valid" if the variable temperature is within the range of -50 trough 150 (both values excluded). 1b.) Given the following declarations int x; int y; Write an if statement that assigns 100 to x when y is equal to 0. 1c.) Given the following declaration: int grade; Write an if statement that prints the message "The number is...
Write spim program and execute it on mars. Your program reads two integer values x and...
Write spim program and execute it on mars. Your program reads two integer values x and y. Write a function called sum that gets x and y passed as parameters and return the sum of odd values between x and y inclusive. In addition write another function called even that gets x and y as parameters and returns the count of all even numbers between x and y inclusive. Also in main print the quotient and remainder of diving y...
Given an integer named area which represents the area of a rectangle, write a function minPerimeter...
Given an integer named area which represents the area of a rectangle, write a function minPerimeter that calculates the minimum possible perimeter of the given rectangle, and prints the perimeter and the side lengths needed to achieve that minimum. The length of the sides of the rectangle are integer numbers. For example, given the integer area = 30, possible perimeters and side-lengths are: (1, 30), with a perimeter of 62 (2, 15), with a perimeter of 34 (3, 10), with...
.Write a for loop to create a list of all the odd numbers between 15 and...
.Write a for loop to create a list of all the odd numbers between 15 and up to and not including 75. Write a second for loop to find the average value in the list, then print it.
Write a function that takes two integer inputs and returns the sum of all even numbers...
Write a function that takes two integer inputs and returns the sum of all even numbers between these inputs, and another function that takes two integer inputs and returns the sum of odd numbers between these inputs .In main function, the program will asks the user to enter two integer numbers and then passes them to these two functions and display the result of each of them.         [0.5 mark] (BY USING C PROGRAM)
Write a program in MASM (32 bit) that calculates the sum of all odd numbers in...
Write a program in MASM (32 bit) that calculates the sum of all odd numbers in the Fibonacci sequence between 0 and 1,000,000. ***Please Complete in MASM 32 bit!!***
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT