Basics of Python-12

Hello, I'm Priya Chakraborty, a dedicated B.Tech student in Electrical Engineering at Siliguri Institute Of Technology. I'm an enthusiastic learner, constantly seeking to expand my skill set and knowledge base. With a solid foundation in programming languages such as C, R, Python, and MySQL, I'm poised to tackle complex technical challenges.
But my passions extend beyond the realm of engineering. I'm also an aspiring content writer, driven by a curiosity to communicate ideas, both technical and non-technical, in a way that captivates and educates.
My journey is defined by a relentless pursuit of self-improvement, coupled with strong communication skills. I believe in the power of continuous learning and the importance of sharing knowledge.
Day-12
While loop :
While loop, here the loop will run until the given condition is satisfied.
the basic syntax of the while loop :
while(expression):
statement (T)
Let's solve a few problems on the while loop:-
- Write a program to print 1 to 10 numbers using a while loop :
num = 1
while num <= 10:
print(num)
num += 1
output :
1
2
3
4
5
6
7
8
9
10
- Write a program to print odd numbers in a range using a while loop
start = 1
end = 20
while start <= end:
if start % 2 != 0:
print(start)
start += 1
output :
1
3
5
7
9
11
13
15
17
19
These are the basic codes using a while loop:-
Write a Python program to print all even numbers between 1 and 50 using a
whileloop.Write a Python program to find the factorial of a number using a
whileloop.Write a Python program to reverse a given number using a
whileloop.Write a Python program to find the sum of digits in a given number using a
whileloop.Write a Python program to check if a given number is a palindrome or not using a
whileloop.Write a Python program to find the GCD of two numbers using a
whileloop.Write a Python program to print the Fibonacci series up to a given number using a
whileloop.Write a Python program to implement a binary search algorithm using a
whileloop.Write a Python program to find the largest and smallest elements in a list using a
whileloop.Write a Python program to simulate a simple guessing game using a
whileloop.
In my next blog, you will get to know about python functions.
Thank you !!




