0% found this document useful (0 votes)
7 views15 pages

Output Based

Uploaded by

Padmasri E
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)
7 views15 pages

Output Based

Uploaded by

Padmasri E
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
You are on page 1/ 15

Write the output of the following code:

[1]:

for i in range(5):

print(i)

[2]:

for i in (1,2,3):

print(i)

[3]:

for i in (2,3,4):

print("i")

[4]:

for i in (4,3,2,1,0):

print(i, end=" ")

[5]:

for i in range(10):

if(i%2!=0):

print("Hello",i)

[6]:

for i in range(10,2,-2):

print(i, "Hello")

[7]:

str = "Python Output based Questions"

word=str.split()
for i in word:

print(i)

[8]:

for i in range(7,10):

print("Python Output based Questions")

print("Python Output based Questions")

[9]:

for i in range(7,-2,-9):

for j in range(i):

print(j)

[10]:

i="9"

for k in i:

print(k)

[11]:

for i in range(1,8):

print(i)

i+=2

[12]:

for i in range(4,7):

i=i+3

print("Hello")
[13]:

for i in range(4,7):

i=i+3

print("Hello",i)

[14]:

i=4

while(i<10):

i=i+3

print(i)

[15]:

for i in range(20):

if i//4==0:

print(i)

[16]:

x=1234

while x%10:

x=x//10

print(x)

[17]:

for i in 1,2,3:

print(i*i)

[18]:

for i in 2,4,6:

print("H"*i)
[19]:

p=10

q=20

p=p*q//4

q=p+q**3

print(p,q)

[20]:

x=2

y=6

x=x+y/2 + y//4

print(x)

[21]:

n=11

for i in range(2,n//2):

if n%i!=0:

print("Python Output based Questions")

break

else:

print("Bye")

[22]:

n=20

for i in range(2,n//4):

if n%i==0:

print("Python Output based Questions")

else:

print("Bye")
[23]:

for i in 123:

print(i)

[24]:

for i in [10,20,30]:

print("Hello",i)

[25]:

x=2

for i in range(x**2,x,-1):

print(x)

[26]:

x=10

for i in range(x):

if x==5:

break

print("H")

print(x)

[27]:

x=6

for i in range(x):

if x==5:

break

print("H")

print(x)
[28]:

s=0

for i in range(5):

s=s+i

print(s)

[29]:

for i in range(1,11):

print("%d"%i)

[30]:

print((3>1) and (9<1))

[31]:

print((9>1) or (9<1))

[32]:

f=0

while(f<10):

print(f)

f=f*3

[33]:

for i in range(5):

for j in range(i):

i=i+j

print(i,end="@")

print(j)
[34]:

i=0

while(i<5):

for j in range(i):

print(j,end="s")

i=i+1

[35]:

num1=7

num2=10

for i in range(5):

num2=num2+10

print(num2)

print(num1)

[36]:

s=0

for i in range(-5,5):

s=s+i

print(s)

[37]:

for i in range(5):

if i%2==0:

pass

else:

print(i)
[38]:

for i in range(5):

if i%2==0:

continue

else:

print(i)

[39]:

for i in range(1,5):

if i%2==0:

break

else:

print(i)

[40]:

for i in range(5):

while(i):

print(i,end=" ")

i=i-1

print()

[41]:

x=5

while(x<15):

print(x**2)

x+=3
[42]:

a=7

b=5

while(a<9):

print(a+b)

a+=1

[43]:

b=5

while(b<9):

print("H")

b+=1

[44]:

b=15

while(b>9):

print("Hello")

b=b-2

[45]:

x=15

while(x==15):

print("Hello")

x=x-3
[46]:

x = "123"

for i in x:

print("a")

[47]:

i=9

while True:

if i%3==0:

break

print("A")

[48]:

a=5

while(a<=10):

print("a")

a+=1

[49]:

i=0

while i<3:

print(i)

i=i+1

else:

print(7)
[50]:

i=0

while i<3:

print(i)

i=i+1

print(0)

[51]:

i=2

for x in range(i):

i+=1

print(i)

print(i)

[52]:

i=2

for x in range(i):

x+=1

print(x)

print(x)

[53]:

i=2

for x in range(i):

x+=1

print(x)

print("x")
[54]:

i=100

while i<57:

print(i)

i+=5

[55]

for i in range(5):

for j in range(i):

print("A",end=" ")

print()

[56]

for i in range(5):

for j in range(i):

print("A",end="a")

print()

[57]

for i in range(5):

print("AS"*i,"\n")

[58]

for i in range(5):

for j in (i):

print("AS"*i,"\n")
[59]

print(10*2//3**2)

[60]

print(12+34-320+23**2)

[61]

a=7

for i in 7:

print(a)

[62]

a = "AKASH"

for i in range(len(a)):

print(a)

[63]

x = "Welcome to my page"

j = "i"

while j in x:

print(j)

[64]

print(range (5, 0, -2))

[65]

for i in range(0,2,-1):

print("Hello")
[66]

s1="cbselearning.com"

s2=""

s3=""

for x in s1:

if(x=="s" or x=="n" or x=="p"):

s2+=x

print(s2,end=" ")

print(s3)

[67]

s1="cbselearning.com"

c=0

for x in s1:

if(x!="l"):

c=c+1

print(c)

[68]

j=12

c=9

while(j):

if(j>5):

c=c+j-2

j=j-1

else:

break

print(j, c)
print(c)

[69]

L = [13 , 12 , 21 , 16 , 35 , 7, 4]

s=5

s1 = 3

for i in L:

if (i % 4 == 0):

s=s+i

continue

if (i % 7 == 0):

s1 = s1 + i

print(s , end=" ")

print(s1)

[70]

print('cs' + 'ip' if '234'.isdigit() else 'IT' + '-402')

You might also like