Last active
November 5, 2019 07:42
-
-
Save anasAlsalol/e76b4914f081bfbc0375b1d2cd142ae1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name = input("Enter file ") | |
| handle = open("sample.txt") | |
| counts = dict() | |
| for line in handle: | |
| words = line.split() | |
| for word in words: | |
| counts[word] = counts.get(word , 0) + 1 | |
| print((v,k) for k,v in counts.items()) | |
| sorted([(v,k) for k,v in counts.items()] ) | |
| bigcount = None | |
| bigword = None | |
| for word,count in counts.items(): | |
| if bigcount is None or count > bigcount: | |
| bigword = word | |
| bigcount = count | |
| print(bigword, bigcount) | |
| '''====================''' | |
| hour = input("Enter Hours") | |
| rate = input("Enter Hours") | |
| pay = float(hour) * float(rate) | |
| print(pay) | |
| '''====================''' | |
| x = 5 | |
| if x == 5 : | |
| print('Equals 5') | |
| if x > 4 : | |
| print('Greater than 4') | |
| if x >= 5 : | |
| print('Greater than or Equals 5') | |
| if x < 6 : print('Less than 6') | |
| if x <= 5: | |
| print('Less than or Equals 5') | |
| if x != 6 : | |
| print('Not equal 6') | |
| '''====================''' | |
| if not (5-5): | |
| print("True") | |
| elif True: | |
| print("elif") | |
| nam = 'anas' | |
| dir(nam) | |
| nam.capitalize() | |
| len(nam) | |
| '''==============''' | |
| data = 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008>>> atpos = data.find('@')' | |
| atpos = data.find('@') | |
| print(atpos) | |
| sppos = data.find(' ',atpos) | |
| print(sppos) | |
| host = data[atpos+1 : sppos] | |
| print(host) | |
| sorted(data , reverse=True) | |
| '''==============''' | |
| words = line.split() | |
| print('Words:', words) | |
| print('Counting...') | |
| for word in words: | |
| counts[word] = counts.get(word,0) + 1 | |
| print('Counts', counts) | |
| d = {'a':10, 'b':1, 'c':22} | |
| print(type(d)) | |
| print(range(1,100)) | |
| d = {'a':10, 'b':1, 'c':22} | |
| t = sorted(d.items() , d.keys()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment