| |
| |
| |
| |
| counter = 100 |
| miles = 1000.0 |
| name = "John" |
| print counter;print miles;print name |
| print("\n") |
| |
| |
| |
| a = b = c = 1 |
| d, e, f = 1, 2, "john" |
| print(a);print(b);print(c);print(d);print(e);print(f) |
| print("\n") |
| |
| |
| |
| |
| number1 = 10 |
| number2 = 10.1 |
| number3 = 0.2 |
| |
| string = "kite" |
| |
| list1 = ['physics', 'chemistry', 1997, 2000] |
| list2 = [1, 2, 3, 4, 5] |
| list3 = ["a", "b", "c", "d"] |
| |
| tup1 = ('physics', 'chemistry', 1997, 2000) |
| tup2 = (1, 2, 3, 4, 5) |
| tup3 = "a", "b", "c", "d" |
| |
| dict1 = {'Alice': '2341', 'Beth': '9102', 'Cecil': '3258'} |
| dict2 = {'abc': 456} |
| dict3 = {'abc': 123, 98.6: 37} |
| print("\n") |
| |
| |
| |
| |
| var1 = 1 |
| var2 = 10 |
| del var2 |
| var3 = 51924361L |
| var4 = 15.20 |
| var5 = 3.14j |
| var6 = 9.322e-36j |
| var7 = complex(3,26) |
| print("\n") |
| |
| |
| |
| nullString = "" |
| if nullString.strip()=='': |
| print("string is null") |
| else: |
| print("string isn't null") |
| |
| string = "123" |
| if string.strip()=="": |
| print("string is null") |
| if string.strip(): |
| print("string isn't null") |
| print("\n") |
| |
| |
| |
| strVal = 'Hello World!' |
| print strVal |
| print strVal[0] |
| print strVal[2:5] |
| print strVal[2:] |
| print strVal * 2 |
| print strVal + "TEST" |
| print("\n") |
| |
| |
| |
| list0 = ['button', 786, 2.23, 'john', 70.2] |
| tinyList = [123, 'john'] |
| print list0 |
| print list0[0] |
| print list0[1:3] |
| print list0[2:] |
| print tinyList * 2 |
| print list0 + tinyList |
| list0[2] = 1000 |
| print list0 |
| print("\n") |
| |
| |
| |
| tup = ('button', 786, 2.23, 'john', 70.2) |
| tinyTuple = (123, 'john') |
| print tup |
| print tup[0] |
| print tup[1:3] |
| print tup[2:] |
| print tinyTuple * 2 |
| print tup + tinyTuple |
| |
| print("\n") |
| |
| |
| |
| dictionary = dict() |
| dictionary['one'] = "This is one" |
| dictionary[2] = "This is two" |
| tinyDict = {'name': 'john', 'code': 6734, 'dept': 'sales'} |
| print dictionary['one'] |
| print dictionary[2] |
| print tinyDict |
| print tinyDict.keys() |
| print tinyDict.values() |
| print("\n") |
| |
| |
| |
| data1 = int(1.2);print(data1);print(type(data1)) |
| data2 = long(98);print(data2);print(type(data2)) |
| data3 = float(1.5);print(data3);print(type(data3)) |
| data4 = complex(12);print(data4);print(type(data4)) |
| data5 = str(12);print(data5);print(type(data5)) |
| data6 = eval(str(14));print(data6);print(type(data6)) |
| data7 = tuple("1234");print(data7);print(type(data7)) |
| data8 = list("1234");print(data8);print(type(data8)) |
| data9 = set("1234");print(data9);print(type(data9)) |
| data10 = dict(a='1', b='2', t='3');print(data10);print(type(data10)) |
| data11 = frozenset("1234");print(data11);print(type(data11)) |
| data12 = chr(65);print(data12);print(type(data12)) |
| data13 = unichr(97);print(data13);print(type(data13)) |
| data14 = ord("a");print(data14);print(type(data14)) |
| data15 = hex(10);print(data15);print(type(data15)) |
| data16 = oct(10);print(data16);print(type(data16)) |