Practical No 5 : Write Python program to demonstrate use of looping statement : "while " loop ,"for loop" and Nested loop ((MSBTE Pratical Question))

1. What would be the output from the following Python code segment
x = 10
while x<5:
    print x,
    x = 1

Ans : Raised an error parenthesis required

2. Change the Python code from using a while loop to for loop:
x =1
while x<10:
    print x
    x+=1

Ans:
for i in range 10:
    print(x)

Comments

Popular posts from this blog

State IDLE in Python.

State use of pep and pip

Program to create user-defined exception that will check whether the password is correct or not? ((MSBTE Pratical Question))