########## variables --- print "TESTING VARIABLES\n" counter = 100 # integer distance = 100.3 # float name = "a string" # string print "inteber: ", counter print "float: ", distance print "string: ", name a = b = c = 33 print "multiple assiggnements, a = b = c = 33: ", a, b, c print "\n\n"; ########### string --- print "TESTING STRING\n" s1 = 'Single "cote" string.' s2 = "Double 'cote' string." s3 = r"Raw string \n don't print special char." s4 = s1 + s2 s4 += s3 print "s1: ", s1 print "s2: ", s2 print "s3: ", s3 print "s4 = s1 + s2 + s3: ", s4 print "\n\n" ########## List --- print "TESTING LIST\n" lst = [0,1,2,3,4,5,6,7,8,9] print "original list: ", lst print "lst[2:5]: ", lst[2:5] print "lst[:5]: ", lst[:5] print "lst[2:]: ", lst[2:] lst.append(10) print "appended list: ", lst lst2 = [1] * 10 print "init long list [1] * 10: ", lst2 print "\n\n" ########## Tuple --- print "TESTING TUPLE\n" tup = ('Jan', 'Fev', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec') print "original tuple: ", tup print "tup[2:5]: ", tup[2:5] print "tup[:5]: ", tup[:5] print "tup[2:]: ", tup[2:] print "\n\n" ########## Dictionary --- print "TESTING DICTIONARY\n" dict = {'Jan': 31, 'Fev': 28, 'Mar': 31, 'Apr': 30} print "original dict: ", dict print "dict['Jan']: ", dict['Jan'] print "keys: ", dict.keys() print "values: ", dict.values() dict['May'] = 31; dict['Jun'] = 30; print "dict with new values: ", dict print "\n\n"
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question