0% found this document useful (0 votes)
1 views2 pages

Internal File

The document contains a series of programming tasks focused on Python, specifically utilizing while loops and other control structures. It includes exercises for printing even numbers, counting digits, generating Fibonacci series, file operations, and determining grades based on marks. The tasks aim to enhance understanding of loops, functions, and file handling in Python.

Uploaded by

Shivam Tiwari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

Internal File

The document contains a series of programming tasks focused on Python, specifically utilizing while loops and other control structures. It includes exercises for printing even numbers, counting digits, generating Fibonacci series, file operations, and determining grades based on marks. The tasks aim to enhance understanding of loops, functions, and file handling in Python.

Uploaded by

Shivam Tiwari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Questions on While Loop in Python

1. Write a program using a while loop to print all even numbers between 1 and 20.
2. Write a Python program using a while loop to count the number of digits in a
number.
3. Write a Python program using a for loop to print numbers from 1 to 10.
4. Explain how a for loop works with the range() function to find prime numbers
from 1 to 100 in Python.
5. Write a Python program using function to find the factorial of a number
6. Write a function to generate Fibonacci series of a given number
7. Write a function to find whether the number is an armstrong number
8. Write a Python program to create a file [Link] and write your name, age, and city into
it. Then read and display the content.
9. Write a Python program to create a file [Link] and count the number of words in it.
10. Write a program to count even and odd numbers in a list
11. Write a program to check Whether a Year is Leap Year
12. Write a program to find Largest Among Three Numbers
13. Write a program to check Whether a Character is Vowel or Consonant
14. Write a Python program to accept marks obtained by a student and display the corresponding
grade using the if-elif-else statement.

Marks Range Grade


90 and above Grade A
75 to 89 Grade B
50 to 74 Grade C
15 Write a Python program to find the sum of first n natural numbers using a while loop.
16 Write a Python program to check whether a number is palindrome or not using a while loop.
17. Write a Python program to print the multiplication table of a given number using a while loop.

18. Write a Python program to perform the following operations using append and read mode
("a+"):

 Open a file named [Link].


 Append a new line into the file.
 Display all contents of the file after appending.

19. Write a Python program to display the third line of a file using the readlines() method.

20. Write a Python program to perform the following operations using read and write mode
("r+"):
 Open a file named [Link].
 Read and display the existing contents of the file.
 Add a new line containing student marks.
 Close the file.

You might also like