Monday, July 25, 2011

Flow Chart to Python Code

(python)
x=1
total=0
while x<=10 :
    math=input("enter marks")
    x=x+1
    total=total+math

avg=total/x-1
if (avg > 50):
   print "Good"
else:
  print "Bad"


Python Code

x=1

total=0
while x<=10 :
    xmath=int(input("enter marks"))
    type(xmath)
    x=x+1
    total=total+xmath

avg=(total/x-1)

if (avg > 50):
   print ("Good")
else:
  print ("Bad")

======================

ffor x in "python-programming":
    print(x)
    if x=='-':
        break
            print x

What is your explanation - will this work ? on indentinng

what are the output of following codes ?

for x in "python-programming":
    print(x)
    if x=='-':
        break
        print (x)

for x in "python-programming":
    print(x)
    if x=='-':
        continue
        print (x)

1 comment:

  1. Good .But u should begin with a simple example.That will be helpful 4 beginners..

    ReplyDelete