Our Office
Ernakulam, Kottayam
Email Us
linusfacts@gmail.com
Call Us
+91 9544409513
1. Ask the user for a number, n.<br>2. Use a while loop to print numbers from 1 to n but skip any number that's divisible by 5 (Tips: You can use the continue statement) 1. Ask the user for a number, n.<br>2. Use a while loop to sum all numbers from 1 to n.<br>3. Print the total. 1. Create a list of integers that can have any length.<br>2. Write a while loop that computes the sum of the numbers of the list one by one.<br>3. The loop should continue adding numbers until a negative number is found.<br>4. If there’s no negative number in the list, the loop continues until all the numbers of<br>the list have been summed 1. Ask the user for a number, n.<br>2. Use a while loop to sum all even numbers from 1 to n (2, 4, 6 …).<br>3. Print the total. 1. Ask the user for a number, n.<br>2. Generate the Collatz sequence starting at n, using a while loop to apply the following rules until you reach the number 1: a. If the number is even, divide it by 2. b. If the number is odd, multiply it by 3 and add 1.<br>3.Print the sequence. 1. Use a while loop to ask the user to guess the number.<br>2. The loop should continue until the user guesses correctly.<br>3. Once the user has guessed the number, print how many tries it took. 1. Use a while loop to count from 1 to n.<br>2. Print each number. 1. Ask the user for a starting number, n.<br>2. Use a while loop to double the value of n until it's greater than 1000.<br>3. Print each doubled value. 1. Ask the user for a number, n.<br>2. Use a while loop to count from n down to 1.<br>3. Print each number

QUESTIONS

1. Ask the user for a number, n.
2. Use a while loop to print numbers from 1 to n but skip any number that's divisible by 5 (Tips: You can use the continue statement)

Right Answer:


n = int(input("Enter a number: "))
count = 1
while count <= n:
if count % 5 != 0:
print(count)
count += 1

1. Ask the user for a number, n.
2. Use a while loop to sum all numbers from 1 to n.
3. Print the total.

Right Answer:


n = 5
sum =0
count=0
while count <=n:
sum+=count
count+=1
print(sum)

1. Create a list of integers that can have any length.
2. Write a while loop that computes the sum of the numbers of the list one by one.
3. The loop should continue adding numbers until a negative number is found.
4. If there’s no negative number in the list, the loop continues until all the numbers of
the list have been summed

Right Answer:



integer_list = [4,8,25,4,69,2,78,-5,0,3,6]
index = 0
total = 0
while index < len(integer_list) and integer_list[index] >= 0:
total += integer_list[index]
index += 1
print(f"The sum is: {total}")

1. Ask the user for a number, n.
2. Use a while loop to sum all even numbers from 1 to n (2, 4, 6 …).
3. Print the total.

Right Answer:

n = int(input("Enter a number: "))
count = 2
total = 0
while count <= n:
total += count
count += 2
print("Total:", total)

1. Ask the user for a number, n.
2. Generate the Collatz sequence starting at n, using a while loop to apply the following rules until you reach the number 1: a. If the number is even, divide it by 2. b. If the number is odd, multiply it by 3 and add 1.
3.Print the sequence.

Right Answer:


n = int(input("Enter a number: "))
sequence = [n]
while n != 1:
if n % 2 == 0:
n = n // 2
else:
n = 3 * n + 1
sequence.append(n)
print("Collatz sequence:", sequence)

1. Use a while loop to ask the user to guess the number.
2. The loop should continue until the user guesses correctly.
3. Once the user has guessed the number, print how many tries it took.

Right Answer:


number = 6
attempts = 0
while attempts < 3:
guess = int(input("Guess a number between 1 and 10: "))
if guess == number:
print("Congratulations! You guessed correctly!")
break
attempts += 1
if attempts == 3:
print("Sorry, you've run out of attempts. Better luck next time!")

1. Use a while loop to count from 1 to n.
2. Print each number.

Right Answer:


n=6
count =1
while count print(count)
count +=1

1. Ask the user for a starting number, n.
2. Use a while loop to double the value of n until it's greater than 1000.
3. Print each doubled value.

Right Answer:


n = int(input("Enter a starting number: "))
while n<= 1000:
print(n)
n *= 2

1. Ask the user for a number, n.
2. Use a while loop to count from n down to 1.
3. Print each number

Right Answer:


n=5
while n >=1:
print(n)
n-=1

Get In Touch

Kochi, Pala,Ernakulam

+91 9544409513

linuslearning.in@gmail.com

Our Courses
Newsletter

Those people who develop the ability to continuously acquire new and better forms of knowledge that they can apply to their work and to their lives will be the movers and shakers in our society for the indefinite future