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 (and test) a Python function that rearranges a sequence of integer values so that all...
Write (and test) a Python function that rearranges a sequence of integer values so that all the even values appear before all the odd values. Make sure to test all common use-cases (ie, an array with all even numbers, one with all odd numbers, and one with a mixture of odd and even numbers). What is the running time of your algorithm? Justify your answer. just not the solution, also need to understand it. Thanks
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
Write Java code that creates an array of primitive integers named odds and stores all odd...
Write Java code that creates an array of primitive integers named odds and stores all odd numbers between -6 and 38 using a for loop. (Your code will populate the array.) Your code should also enable the array’s size to be exactly large enough to store the numbers. (You will not put a number for the size, your code will determine the number.) (5 pt)
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
6.         Write a single statement that prompts the user to enter their age in years and places...
6.         Write a single statement that prompts the user to enter their age in years and places the integer value in a variable named age. 7.         Can a program place more than one statement on the same program line? 8.         Write a short code segment in Python that prompts the user to enter the number of quarters, dimes, nickels and pennies they have, compute the total value and print that value.
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...
All in C language... Write a complete program that declares an integer variable, reads a value...
All in C language... Write a complete program that declares an integer variable, reads a value from the keyboard into that variable, and writes to standard output the variable's value, twice the value, and the square of the value, separated by spaces. Besides the numbers, nothing else should be written to standard output except for spaces separating the values. I got this... and it's wrong #include<stdio.h> int main() { int num; scanf("%d", &num); printf("%d %d %d",num,2*num,num*num); return 0; }
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...