Skip to content

Commit c6200d0

Browse files
Add files via upload
1 parent d35adf9 commit c6200d0

16 files changed

+194
-0
lines changed

Python/code/helloworld.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print('Hello World')

Python/code/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello World")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
a = 21
2+
b = 10
3+
c = 0
4+
c = a + b
5+
print ("Line 1 - Value of c is ", c)
6+
c = a - b
7+
print ("Line 2 - Value of c is ", c )
8+
c = a * b
9+
print ("Line 3 - Value of c is ", c)
10+
c = a / b
11+
print ("Line 4 - Value of c is ", c )
12+
c = a % b
13+
print ("Line 5 - Value of c is ", c)
14+
a = 2
15+
b = 3
16+
c = a**b
17+
print ("Line 6 - Value of c is ", c)
18+
a = 10
19+
b = 5
20+
c = a//b
21+
print ("Line 7 - Value of c is ", c)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
a = 21
2+
b = 10
3+
c = 0
4+
c = a + b
5+
6+
print ("Line 1 - Value of c is ", c)
7+
c += a
8+
print ("Line 2 - Value of c is ", c )
9+
c *= a
10+
print ("Line 3 - Value of c is ", c )
11+
c /= a
12+
print ("Line 4 - Value of c is ", c )
13+
c = 2
14+
c %= a
15+
print ("Line 5 - Value of c is ", c)
16+
c **= a
17+
print ("Line 6 - Value of c is ", c)
18+
c //= a
19+
print ("Line 7 - Value of c is ", c)

Python/code/pythonbitwiseoperators.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
a = 60 # 60 = 0011 1100
2+
b = 13 # 13 = 0000 1101
3+
print ('a=',a,':',bin(a),'b=',b,':',bin(b))
4+
c = 0
5+
c = a & b; # 12 = 0000 1100
6+
print ("result of AND is ", c,':',bin(c))
7+
c = a | b; # 61 = 0011 1101
8+
print ("result of OR is ", c,':',bin(c))
9+
c = a ^ b; # 49 = 0011 0001
10+
print ("result of EXOR is ", c,':',bin(c))
11+
c = ~a; # -61 = 1100 0011
12+
print ("result of COMPLEMENT is ", c,':',bin(c))
13+
c = a << 2; # 240 = 1111 0000
14+
print ("result of LEFT SHIFT is ", c,':',bin(c))
15+
c = a >> 2; # 15 = 0000 1111
16+
print ("result of RIGHT SHIFT is ", c,':',bin(c))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
a = 21
2+
b = 10
3+
if ( a == b ):
4+
print ("Line 1 - a is equal to b")
5+
else:
6+
print ("Line 1 - a is not equal to b")
7+
if ( a != b ):
8+
print ("Line 2 - a is not equal to b")
9+
else:
10+
print ("Line 2 - a is equal to b")
11+
if ( a < b ):
12+
print ("Line 3 - a is less than b" )
13+
else:
14+
print ("Line 3 - a is not less than b")
15+
if ( a > b ):
16+
print ("Line 4 - a is greater than b")
17+
else:
18+
print ("Line 4 - a is not greater than b")
19+
a,b=b,a #values of a and b swapped. a becomes 10, b becomes 21
20+
if ( a <= b ):
21+
print ("Line 5 - a is either less than or equal to b")
22+
else:
23+
print ("Line 5 - a is neither less than nor equal to b")
24+
if ( b >= a ):
25+
print ("Line 6 - b is either greater than or equal to b")
26+
else:
27+
print ("Line 6 - b is neither greater than nor equal to b")

Python/code/pythondictionary.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dict = {}
2+
dict['one'] = "This is one"
3+
dict[2] = "This is two"
4+
tinydict = {'name': 'john','code':6734, 'dept': 'sales'}
5+
print (dict['one']) # Prints value for 'one' key
6+
print (dict[2]) # Prints value for 2 key
7+
print (tinydict) # Prints complete dictionary
8+
print (tinydict.keys()) # Prints all the keys
9+
print (tinydict.values()) # Prints all the values
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
a = 20
2+
b = 20
3+
print ('Line 1','a=',a,':',id(a), 'b=',b,':',id(b))
4+
5+
if a is b:
6+
print("Line 2 - a and b have same identity")
7+
else:
8+
print("Line 2 - a and b do not have same identity")
9+
if id(a) == id(b):
10+
print("Line 3 - a and b have same identity")
11+
else:
12+
print("Line 3 - a and b do not have same identity")
13+
14+
b = 30
15+
print('Line 4','a=',a,':',id(a), 'b=',b,':',id(b))
16+
17+
if a is not b:
18+
print("Line 5 - a and b do not have same identity")
19+
else:
20+
print("Line 5 - a and b have same identity")

Python/code/pythonifstatement.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var1 = 100
2+
if var1:
3+
print ("1 - Got a true expression value")
4+
print (var1)
5+
6+
var2 = 0
7+
if var2:
8+
print ("2 - Got a true expression value")
9+
print (var2)
10+
print ("Good bye!")

Python/code/pythonlists.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
2+
tinylist = [123, 'john']
3+
print (list) # Prints complete list
4+
print (list[0]) # Prints first element of the list
5+
print (list[1:3]) # Prints elements starting from 2nd till 3rd
6+
print (list[2:]) # Prints elements starting from 3rd element
7+
print (tinylist * 2) # Prints list two times
8+
print (list + tinylist) # Prints concatenated lists

Python/code/pythonlogicaloperators.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
a = 10
2+
b = 20
3+
list = [1, 2, 3, 4, 5 ]
4+
5+
if( a in list ):
6+
print("Line 1 - a is available in the given list")
7+
else:
8+
print("Line 1 - a is not available in the given list")
9+
if( b not in list ):
10+
print("Line 2 - b is not available in the given list")
11+
else:
12+
print("Line 2 - b is available in the given list")
13+
c=b/a
14+
if ( c in list ):
15+
print("Line 3 - a is available in the given list")
16+
else:
17+
print("Line 3 - a is not available in the given list")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
a = 20
2+
b = 10
3+
c = 15
4+
d = 5
5+
print ("a:%d b:%d c:%d d:%d" % (a,b,c,d ))
6+
e = (a + b) * c / d #( 30 * 15 ) / 5
7+
print ("Value of (a + b) * c / d is ", e)
8+
e = ((a + b) * c) / d # (30 * 15 ) / 5
9+
print ("Value of ((a + b) * c) / d is ", e)
10+
e = (a + b) * (c / d) # (30) * (15/5)
11+
print ("Value of (a + b) * (c / d) is ", e)
12+
e = a + (b * c) / d # 20 + (150/5)
13+
print ("Value of a + (b * c) / d is ", e)

Python/code/pythonstrings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
str = 'Hello World!'
2+
print (str) # Prints complete string
3+
print (str[0]) # Prints first character of the string
4+
print (str[2:5]) # Prints characters starting from 3rd to 5th
5+
print (str[2:]) # Prints string starting from 3rd character
6+
print (str * 2) # Prints string two times
7+
print (str + "TEST") # Prints concatenated string

Python/code/pythontuple.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
2+
tinytuple = (123, 'john')
3+
print (tuple) # Prints complete tuple
4+
print (tuple[0]) # Prints first element of the tuple
5+
print (tuple[1:3]) # Prints elements starting from 2nd till 3rd
6+
print (tuple[2:]) # Prints elements starting from 3rd element
7+
print (tinytuple * 2) # Prints tuple two times
8+
print (tuple + tinytuple) # Prints concatenated tuple

Python/code/variales.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name = "Gyan"
2+
age = 21
3+
4+
print(name)
5+
print(age)

Python/code/wordcloud.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import matplotlib.pyplot as pPlot
2+
from wordcloud import WordCloud, STOPWORDS
3+
import numpy as npy
4+
from PIL import Image
5+
dataset = open("sampleWords.txt", "r").read()
6+
defcreate_word_cloud(string):
7+
maskArray = npy.array(Image.open("cloud.png"))
8+
cloud = WordCloud(background_color = "white", max_words = 200, mask = maskArray, stopwords = set(STOPWORDS))
9+
cloud.generate(string)
10+
cloud.to_file("wordCloud.png")
11+
dataset = dataset.lower()
12+
create_word_cloud(dataset)

0 commit comments

Comments
 (0)