age=int(raw_input("Enter your age: "))
if(age>12 and age<20):
print "you are a teen-aged person. good!"
age=int(raw_input("Enter your age: "))
if(age<0):
print "I am sorry!"
print "age can never be negative"
if(age>12 and age<20):
print "you are a teen-aged person. good!"
big=float
a, b, c=[float(x) for x in raw_input("Enter three floating-point numbers: ").split()] #taking input in single line separated by white space
big=a
if(b>big):
big=b
if(c>big):
big=c
print "Largest of the three numbers =", big
age=int(raw_input("Enter your age: "))
if(age>12 and age<20):
print "you are a teen-aged person. good!"
else:
print "you are not a teen-aged person."
years=float(raw_input("Enter your age in years: "))
if(years<0):
print "I am sorry! age can never be negative"
else:
secs=years*365*24*60*60
print "You have lived for %.4g seconds" %(secs)
age=int(raw_input("Enter your age: "))
if(age>12 and age<20):
print "you are a teen-aged person. good!"
else:
if(age<13):
print "you will surely reach teen-age."
else:
print "you have crossed teen-age!"
n=int(raw_input("How many integers to be displayed: "))
for i in range(n):
print i
Sum=0
sum_of_squares=0
for i in range(2, 31, 2):
Sum+=i
sum_of_squares+=i*i
print "Sum of first 15 positive even numbers =", Sum
print "Sum of their squares =", sum_of_squares
Sum=0
sum_of_squares=0
for i in range(30, 0, -2):
Sum+=i
sum_of_squares+=i*i
print "Sum of first 15 positive even numbers =", Sum
print "Sum of their squares =", sum_of_squares
i=1
for i in range(i, 11):
print i*5,
n=int(raw_input("Enter the number of lines: "))
for p in range(1, n+1):
for q in range(1, n-p+1):
print "\t",
m=p
for q in range (1, p+1):
print "\t", m,
m+=1
m=m-2
for q in range(1, p):
print "\t", m,
m-=1
print ''
n=int(raw_input("How many integers to be displayed: "))
i=0
while i<n:
print i
i+=1
Sum=0
count=0
print "Enter the marks, -1 at the end..."
marks=int(raw_input())
while marks!=-1:
Sum+=marks
count+=1
marks=int(raw_input())
average=Sum/count
print "The average is", average
decimal=0
position=0
binary=int(raw_input("Enter the binary number: "))
while binary:
digit=binary%10
decimal+=digit<<position
binary/=10
position+=1
print "Its decimal equivalent =", decimal
n=int(raw_input("How many integers to be displayed: "))
i=0
while 1: #do while loop
print i
i+=1
if i>=n:
break
while 1: #do-while loop
inchar=raw_input("Enter your sex (m/f): ")
if(inchar=='m' or inchar=='f'):
break
if inchar=='m':
print "so you are male. good!"
else:
print "so you are female. good!"
rev=0
num=int(raw_input("Enter the number: "))
n=num
while 1:
digit=num%10
rev=rev*10 + digit
num/=10
if num==0:
break
print "Reverse of the number =", rev
if n==rev:
print "The number is a palindrome"
else:
print "The number is not a palindrome"
Sum=0
count=0
print "Enter the marks, -1 at the end..."
while 1:
marks=int(raw_input())
if marks==-1:
break
Sum+=marks
count+=1
average=Sum/count
print "The average is", average
ch=raw_input("Enter your sex (m/f): ")
if ch=='m':
print "So you are male. good!"
elif ch=='f':
print "So you are female. good!"
else:
print "Error: Invalid sex code!"
print "------------------Basic Calculator------------------"
print "Choose an option:"
print "Add"
print "Subtract"
print "Multiply"
print "Divide"
ch=raw_input()
num1, num2=[int(x) for x in raw_input("Enter the value of the operands: ").split()]
if ch=='1':
print num1+num2
elif ch=='2':
print num1-num2
elif ch=='3':
print num1*num2
elif ch=='4':
print num1/num2
else:
print "Incorrect choice: "
total=0
while 1:
num=int(raw_input("Enter a number (0 to quit): "))
if num==0:
print "end of data entry."
break
if num<0:
print "skipping this number."
continue
total+=num
print "Total of all +ve numbers is ", total
total=0
while 1:
num=int(raw_input("Enter a number (0 to quit): "))
if num==0:
print "end of data entry."
print "Total of all +ve numbers is", total #no goto in python
break
if num<0:
print "skipping this number."
continue
total+=num
age=int(raw_input("Enter your age: "))
if(age>12 and age<20):
pass
print "you are a teen-aged person. good!"
myage=25
print "Hi! my age is ", myage
yourage=int(raw_input("What is your age? "))
if myage==yourage:
print "We are born on the same day. Are we twins!"
l1=int(raw_input("Enter the lower limit: "))
l2=int(raw_input("Enter the higher limit: "))
print "The prime numbers between", l1, "and", l2, "are: ",
for i in range(l1, l2+1):
if i<=3:
print i,"\t",
else:
for j in range(2, i/2+1):
if(i%j==0):
break
if(i%j==0):
continue #no goto
print i, "\t",