2. Using a “for loop” print all even numbers in rage from 1 to 1000. Also, please count and print how many even numbers you have found.
3. Using the following list and a “for” loop, display differences of all consecutive pairs of numbers in the list.
our_list = [1,2,5,6,3,77,9,0,3,23,0.4,-12.4,-3.12] The output should look like this: 1 3 1 …
4. Using a “while loop” ask the user for a number and add it to a list if number is even and to a different list if number is odd. Keep asking the user for a number until he says “I’m bored” and doesn't want to give you any more numbers.
5. For the following list, print each element in the list an it’s type. What did you find interesting when solving this question? What worked different than you expected?
list5 = ['a','b',1,2,[1,2,3,4],'hello',(4,5,6),7,True,"False",2.3]
c=0;
for i in range(1,1001):
if(i%2==0):
print(i, end =" ")
c=c+1
print()
print("Total even no. is",c)
Get Answers For Free
Most questions answered within 1 hours.