From 139acf794c436bc23dc92c8efe279202c2c8c9b9 Mon Sep 17 00:00:00 2001 From: varunpanicker Date: Fri, 23 Jun 2017 04:41:08 +0000 Subject: [PATCH] Done --- .README.md.swp | Bin 0 -> 1024 bytes practice.py | 66 ++++++++++++++++++++++++++++++++++++++++ tests/__init__.pyc | Bin 0 -> 162 bytes tests/test_solution.pyc | Bin 0 -> 693 bytes 4 files changed, 66 insertions(+) create mode 100644 .README.md.swp create mode 100644 tests/__init__.pyc create mode 100644 tests/test_solution.pyc diff --git a/.README.md.swp b/.README.md.swp new file mode 100644 index 0000000000000000000000000000000000000000..0e9bf1a882baacd677d92f3405a2348f6b5073a1 GIT binary patch literal 1024 zcmYc?$V<%2S1{5u)iY*50>&W>3}uN$rFjL3d6~)CsYOU~=*-LlT|;vtU1LLCb6q1t eLv(34KgiY5#n)9YHw7*-$`}oS(GVEO5C8ya!Vg#g literal 0 HcmV?d00001 diff --git a/practice.py b/practice.py index e69de29..1cfa81c 100644 --- a/practice.py +++ b/practice.py @@ -0,0 +1,66 @@ +a= "Hello, this is the test exercise" +print a + +#Comparing memory alloation blocks of strings in python +s1= "qwerty" +s2= "qwerty" +def printstring(): + print "string 1 is: ", s1 + print "string 2 is: ", s2 +printstring() + +def printid(): + print "id of string 1 is: ", id(s1) + print "id of string 2 is: ", id(s2) + global ids2 + ids1= id(s1) + ids2= id(s2) + print "this is calling the local variable ids1 for id of s1", ids1 +printid() + +print "this is calling the global variable ids2 for id of s2", ids2 + +print "if id of s1 and s2 are the same, memory alloc is a match" + +print "type() function is used to view the type of the variable defined" +n1= 12345 +print "value of n1 is", n1 +print "type of the n1 variable is", type(n1) + +def lists(): + print "lists are a data structure in python" + print "lists in python are heterogeneous, they house various datatypes" + a= [1,2,3,"aaaaa"] + print a + print (a, "is of type", type(a)) +lists() + +def dictionary(): + print "dictionaries are a data structure in python" + print "dictionaries are represented as 'dict' " + a= {"big data" : "data"} + print a + print (a, "is of type", type(a)) +dictionary() + +def append(): + print "demonstrating append for lists" + l=[1,2,3,4] + print l + l.append(5) + print l +append() + +def importing(): + print "to import math library, type 'import math'" + import math + print "type of math library is", type(math) + print (math.sqrt(16)) +importing() + +print """use tripple double quotes to write multiline strings, +Just like this!""" + +string= "test case for strings" +print "characters form index 1 to -5: ", (string[1:-5]) +print (len(string)) diff --git a/tests/__init__.pyc b/tests/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..377996043ce0914a029872b9af776f01e32c84fd GIT binary patch literal 162 zcmZSn%*(aVNi#B;0SXv_v;zW|fEmIf zJtKJeLn{?@3m24@7Q;-T4VQ;v;j1o`-W|ypI;FsCN*0)dC}}cHEf#T-W(>!GVnz|M z9{{gW+n!Yc@pF3~drUjg#EX+gAzITb8WDiYHZ0rD_HRR;XRA$0C&YwLbj!ECw)vZC zJJ%>z>YZ)#XW#CyQQGF(8=IFdv_1}wyX-|_sWA`4-Dio1&)yMYOhdVKd}Ozf zC4)%W@#vS7PSsY*z*42Gz3D0{3s!kj_;)f3wmDkD%Ff07B&~C0;13kkfQb7KLD7}_ N-iHSk7cIL=egOrQs9OL4 literal 0 HcmV?d00001