-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTricks.py
More file actions
180 lines (132 loc) · 4.28 KB
/
Tricks.py
File metadata and controls
180 lines (132 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 13 17:29:50 2021
@author: DELL
"""
# There is actually a poem on python which can be read by just writing import this
import this
'''
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
'''
a="Priyanka"
print(a*4)# You can print a string stored in a variable x n times using command
b=['1','2','3','4','5','6']
print("".join(b))#It will create a single list from all teh eleemnts in list b
c=float("inf")
print(c)# We can define 'infinity' in python using float('inf')
dict={'flavour': 'strawberry'}
print(dict)
dict.clear()#It removes all the elements of dictionary dict
print(dict)
e=3
f=34
e,f=f,e# swap the numbers
print(e, f)
#compare the two lists
list1 = ["fg","fg", "rt", "fg", "lllf"]
list2 = ["fg","fg", "rt", "fg", "lf"]
a = set(list1)
b = set(list2)
print(a)
print(b)
if a == b:
print("The list1 and list2 are equal")
else:
print("The list1 and list2 are not equal")
# Define Positive infinity number
ptive_inf = float('inf')
if 99999999999999999 > ptive_inf:
print('Number is greater than Positive infinity')
else:
print('Positive infinity is greater')
# Define Negative infinity number
ntive_inf = float('-inf')
if -99999999999999999 > ptive_inf:
print('Numer is smaller than Negative infinity')
else:
print('Negative infinity is smaller')
#using of *before list_name to showing elements of list
n=int(input())
matrix=[]
count=0
for row in range(0,n):
temp=[]
for col in range(0,n):
count+=1
temp.append(count)
matrix.append(temp)
for r in matrix[:-1]:
print(r)
print(*r)
print(matrix[-1], end=" ")
print(*matrix[-1], end=" ")
#time.time() returns the current time in milli seconds since midnight, jan 1, 1970
import time
print(time.time())
#ord() funciton converts a character into its ASCII notation
print(ord('A'))
#-----#
import nltk
from nltk.tokenize import sent_tokenize
from nltk.corpus import stopwords
text1="Welcome to programming. Programming is fun."
text2=" More fun is to program with Python. "
text3="Python is simple yet very vast with multiple functionalities."
text4="So, come enjoy programming with Python."
mytext=text1+text2+text3+text4
print(mytext)
tokens=[t for t in mytext.split()]
sr=stopwords.words('english')
clean_tokens=tokens[:]
freq=nltk.FreqDist(tokens)
freq.plot(20, cumulative=False)
#-----------------------#
import nltk
from nltk.tokenize import sent_tokenize
from nltk.corpus import stopwords
text1="Welcome to programming . Programming is fun ."
text2=" More fun is to program with Python ."
text3=" Python is simple yet very vast with multiple functionalities ."
text4=" So, come enjoy programming with Python"
mytext=text1+text2+text3+text4
print(mytext)
tokens=[t for t in mytext.split()]
sr=stopwords.words('english')
clean_tokens=tokens[:]
freq=nltk.FreqDist(tokens)
freq.plot(20, cumulative=False)
####------------------####
import nltk
from nltk.tokenize import sent_tokenize
from nltk.corpus import stopwords
text1="Welcome to programming. Programming is fun."
text2=" More fun is to program with Python. "
text3="Python is simple yet very vast with multiple functionalities."
text4="So, come enjoy programming with Python."
mytext=text1+text2+text3+text4
tokens=[t for t in mytext.split()]
clean_tokens=tokens[:]
for token in tokens:
if token in stopwords.words('english'):
clean_tokens.remove(token)
freq=nltk.FreqDist(clean_tokens)
freq.plot(20, cumulative=False)