Join Our WhatsApp Group Join Subscribe Now!

Basic Python Programming (313011) Practical No.5 Write a simple Python program to demonstrate use of control loops: i) while ii) do while

Basic Python Programming (313011) Practical No.5 Write a simple Python program to demonstrate use of control loops: i) while ii) do while

 Basic Python Programming (313011) Practical No.5 Write a simple Python program to demonstrate use of control loops:  i) while ii) do while

Control loops are essential for solving iterative problems by automating repetitive tasks and processing data collections efficiently. They are crucial in implementing algorithms like sorting and searching and handling dynamic input gracefully. In concurrent processing, loops manage multiple tasks simultaneously, enhancing performance and scalability in software applications.

313011

Practical related questions

1. Write a program to convert a binary number (input as a string) to its decimal equivalent using looping constructs.

Answer:

313011

2. Implement a program to convert a decimal number (input as an integer) to its binary equivalent using looping constructs.

Answer:


3. Implement a program to count the number of ones in a binary number (input as a string) using looping constructs.

Answer:



4. Implement a program to calculate the output voltage of a voltage divider circuit using given resistor values and an input voltage. Use looping constructs to iterate through different resistor combinations and calculate the output voltage.

Answer:


Exercise:

1. Write a Python program to print all even numbers between 1 to 100 using while loop.

Answer:

number = 2

while number <= 100:

  print(number)

  number += 2


2. Write a Python program to find the sum and reverse of n-digit numbers using for loop.

Answer:


3. Write a Python program to print Fibonacci series on any number entered by the user.

Answer:


4. Write a Python program to calculate factorial of a number.

Answer:


5. Write a Python to print the LCM and GCD of two non-negative integer numbers.

Answer:


6. Write a Python program which will print all the Armstrong numbers between 1 to 500.

Answer:


7. Write a Python program that takes a number and checks whether it is a palindrome or not.

Answer:





About the Author

Hi everyone, I'm Suraj Diware, and I'm passionate about helping students succeed in MSBTE programs. This blog is dedicated to providing clear and concise explanations of MSBTE curriculum topics, along with practical tips and resources to sup…

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.