You are on page 1of 3

print ("hello world");

print ("hello world");


print ('hello world');
'''
This is a multi line
comment
'''
print ('Hello, world');
"""
THIS IS A MULTI LINE COMMENT
"""
print ("hello wor")

if 'True':
print ("True")
else:
print ("false")

if 'true':
print('answer')
print('true')
else:
print('answer')
print('false')

print(' $ ')
print('$$$')
print(' $ ')

print("""this is python""")

print("w\tw")
print(" w w w")
print(" w")
print(" w w w")
print("w\tw")

#writing multiple statements

print("hai");print('hello')

#printing hello 'hi' bye 'why'

print("hello \'hi\' bye \'why\'")


print ('hai \'hello\' \\how\\')

'''#working with raw_input


#in python 3.x 'input' is keyword whereas in 2.x 'raw_input'
#print(raw_input('enter:')))

#raw_input takes only input as string


a=raw_input('enter a:')
b=raw_input('enter b:')
c=a+b
print c
print type(a)
#input takes whether it is int returns int,if input is string return string
a=input('enter a:')
b=input('enter b:')
c=a+b
print c
print type(a)

str = input("Enter your input: "); #complex program can be given as input.The
input() function evaluates it.
print "Received input is : ", str

'''
#range() function

#for 1 parameter
for i in range(5):
print i
print '----------'

#for 2 parameters
for i in range(3,6):
print i
print '----------'

#for 3 parameters
for i in range(1,10,2):
print i
print '----------'

#printing backwards
for i in range(0,-10,-2):
print i
print '----------'

#output operations

print 'string needs quotes'


print 1,2,3
print 1,2, 3
print '----------'

for i in range(10):
print i,
print

for i in range(1,10):
print i,
print #here print statement without any object enters into new
line
for i in range(10,20):
print i,
print
print '----------'

#not omitting spaces


print 1,2,(10+5j),-0.999
#omitting spaces by using concatenation
print str(1)+str(2)+str((10+5j))+str(-0.999)
print '----------'

import sys
write = sys.stdout.write
write('20')
write('05')
print('\nhai \nhello')
print '----------'

#String indices
string='PYTHON TUTORIAL'
print (string[0])
print (string[3])
print (string[6])
print (string[14])
#print(string[15]) #index out of range
print '\n----------'

#to check char in a string


x="PYTHON"
ch=input('enter char to check:')
print ch in x
print '\n----------'

apples=22
bananas=20
carrots=30
print"I have "+str(apples)+" apples "+str(bananas)+" bananas "+str(carrots)+"
carrots"

You might also like