Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # basic_test.py
- import string
- # this is a comment
- print "hello python world"
- print """this
- spans more than one line"""
- print "hello python world\n"
- print "hello python world "*3
- print "hello python",
- print "world"
- print "hello python world\
- over more than one line"
- print("this is it again")
- print r"\this is a raw string\\"
- print "\thello python world"
- print "hello"+'''python'''+'world'
- print "hello python world".capitalize()
- print "hello python world".isspace()
- print "hello python world".istitle()
- print "hello python world".isupper()
- print "hello python world".islower()
- print "hello python world".isalnum()
- print "hello python world".isdigit()
- print "hello python world".isalpha()
- print "hello python world".upper()
- print "hello python world".lower()
- print "hello python world".title()
- print "hello python world".count("l")
- print len("hello python world")
- print "hello python world".startswith("h")
- print "hello python world".endswith("d")
- print "hello python world".find("y",1)
- print "hello python world".replace("l","X")
- print "hello python world".center(36)
- print "hello python world".center(36,"-")
- print "hello python world".swapcase()
- print "hello python world".partition("l")
- print "hello python world".rsplit()
- print "hello python world".ljust(30,'!')
- print "hello python world".rjust(30,'*')
- print "hello python world".split()
- print "hello python world".split('l')
- print """
- hello python world
- hello python world
- hello python world""".splitlines()
- print " hello python world ".strip() + '!!!'
- z=["hello","python","world"]
- print "-".join(z)
- print "*".join("hello python world")
- print "ytho" in "hello python world"
- print "hello python world"[4:]
- print "hello python world"[:8]
- print "hello python world"[:-3]
- print "hello python world"[::-1]
- print "hello python world"[::2]
- s = "the quick brown fox jumps over the lazy dog"
- print string.capwords(s)
- f = string.maketrans("aeiou","12345")
- print string.translate(s,f)
- a = 1; b = "house"; c = 5; d = "e"
- print "%d %s +0.5%f %c" % (a,b,c,d)
- print("$%.2f" % (19.946))
- r = 5
- print "%f +1.2%f 2%f" % (r,r,r)
- w = 10
- if w == 10:
- print "true"
- if w != 10:
- print "true"
- else:
- print "this is not true"
- if w is 10:
- print "hello python world "
- elif w != 10:
- print "false"
- else:
- print "true"
- end = 10
- while end != 0:
- end -=1
- if end % 2 ==0:
- print end,"even"
- else:
- print end,"odd"
- print "7".zfill(3)
- print all([True, True, True, False, True, True])
- print any([True, True, True, False, True, True])
- numbers = [1,2,3,4,5,6,7,8,9]
- if any(z > 3 for z in numbers):
- print "there are numbers greater than 3"
- print all(z > 3 for z in numbers)
- print any(z in [3,6,9] for z in [1,2,3,4,5])
- print any(z in [6,9,12] for z in [1,2,3,4,5])
- x = 3; z = 5
- if (x>2) and (x!=5):
- print "this is true"
- if (z == 3) or (z != 5):
- print "this is true"
- start = 10
- while start != 0:
- start -= 1
- print start
- print "\n"
- begin = 10
- while begin:
- if begin == 2:
- break
- begin -=1
- print begin
- print"\n"
- begin = 10
- while begin:
- begin -= 1
- if begin == 6:
- continue
- print begin
- myList = [1,2,3]
- for i in myList:
- print i
- print range(10)
- names = ['John', 'Mark', 'Henry', 'Marie', 'Mark', 'Marie', 'Jen']
- for i in names:
- if names.count(i) > 1:
- print i
- print list(set(names))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement