Skip to content

Commit c5e4668

Browse files
authored
Add files via upload
1 parent b65112f commit c5e4668

File tree

83 files changed

+3589
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3589
-0
lines changed

Programs/Chatbot.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# -*- coding: utf-8 -*-
2+
import nltk
3+
from nltk.chat.util import Chat, reflections
4+
5+
reflections = {
6+
"i am" : "you are",
7+
"i was" : "you were",
8+
"i" : "you",
9+
"i'm" : "you are",
10+
"i'd" : "you would",
11+
"i've" : "you have",
12+
"i'll" : "you will",
13+
"my" : "your",
14+
"you are" : "I am",
15+
"you were" : "I was",
16+
"you've" : "I have",
17+
"you'll" : "I will",
18+
"your" : "my",
19+
"yours" : "mine",
20+
"you" : "me",
21+
"me" : "you",
22+
23+
}
24+
pairs = [
25+
[
26+
r"my name is (.*)",
27+
["Hello %1, How are you today ?",]
28+
],
29+
[
30+
r"hi|hey|hello",
31+
["Hello", "Hey there",]
32+
],
33+
[
34+
r"what is your name ?|your name|name please",
35+
["I am Y2K. You can call me crazy individual!",]
36+
],
37+
[
38+
r"how are you ?|how you doing|what about you|how about you ?",
39+
["I'm doing good. How can I help you ?",]
40+
],
41+
[
42+
r"sorry (.*)",
43+
["Its alright","Its OK, never mind",]
44+
],
45+
[
46+
r"I am fine",
47+
["Great to hear that, How can I help you?",]
48+
],
49+
[
50+
r"(.*) continents",
51+
["Asia, Africa, North America, South America, Antarctica, Europe, and Australia ",]
52+
],
53+
[
54+
r"(.*) (english|hollywood) movie",
55+
["The Shawshank Redemption", " The Lord of the Rings: The Return of the King","Inception", "Interstellar", "Parasite", "Twilight", "Fast & Furious", "Lucky one","A walk to remember", "The Last Song", "The Notebook","The Fault in Our Stars", "Joker", "Me Before You", "All the boys have met before","Kissing booth", "Titanic",]
56+
],
57+
[
58+
r"i'm (.*) doing good",
59+
["Nice to hear that","How can I help you?:)",]
60+
],
61+
[
62+
r"(.*) age?|are you an (idiot|stupid)|what do you think you are",
63+
["I'm a computer program dude....Seriously you are asking me this?",]
64+
],
65+
[
66+
r"(.*) (online|free) courses",
67+
["Udemy","Udacity","Great Learning","Google Digital Garage","Swayam",]
68+
],
69+
[
70+
r"(.*) (news channel|news)",
71+
["BCC World News","Fox News","Cable News Network (CNN)","Sky News","MSNCB","Republic World","ZEE News","ABP News",]
72+
],
73+
[
74+
r"(.*) (horror|spooky) movie",
75+
["The Nun", "Annabelle", "The conjuring", "Sinister", "The cabin in the wood", "insidious", "IT","Ouija", "Train to Busan", "The Ring", "Hush", "Evil Dead", "Oculus",]
76+
],
77+
[
78+
r"(.*) (bollywood|hindi) movie",
79+
["War", "My name is Khan", "Happy new year", "Dilwale", "Uri", "Don", "Don 2", "Raees","Raazi", "Kalank", "Kalank", "Dangal", "LUDO", "Good Newz", "PK", "Jab Tak Hai Jaan","Cocktail", "Bahubali", "M.S.Dhoni", "Aashiqui 2","Dear Zindagi","Anand", "Mughal-E-Azam", "Mother India", "Don ", " Parinda", "Mr. India","Mera Naam Joker", "Amar, Akbar and Anthony", " Agneepath ", "Sahib Bibi Aur Ghulam","Sholay",]
80+
],
81+
[
82+
r"(.*) (webseries|series)",
83+
["You", "Lucifer", "Cursed", "Mismatched", "Money Heist", "Stranger Things", "Merlin","The Protector", "Sabrina", "Dark", "Friends", "The Big Bang Theory", "Little Things","Lock & Key", "Sherlock", "Sweet Tooth", "The Witcher", "Shadow and Bones","Never Have i ever", "Brooklyn Nine-Nine", "Ragnarok", "Originals", "Vampire Diaries","The Order", "The Boss Baby", "The Haunting of Hill House", "Pup Academy", "Mary Queen of Scots","Bitten", "Titans", "Warrior Nun","The Haunting of bly Manor",]
84+
],
85+
[
86+
r"(.*) k-drama",
87+
["descendants of the sun","busted", "her private life", "whats wrong with secretary kim","its okay to not be okay", "hospital playlist", "crash landing on you","weightlifting fairy kim bok joo", "my first first love", "beauty inside", "was it love",]
88+
],
89+
[
90+
r"(.*) (novel|book)",
91+
["Harry Potter", "Twilight", "Alchemist", "Angel And Demon", "Dead Beautiful", "Lost Symbol", "The Vinche Code", "Hunger Games",]
92+
],
93+
[
94+
r"(.*) created ?",
95+
["I am created using Python's NLTK library ","top secret",]
96+
],
97+
[
98+
r"(.*) band",
99+
["BTS", "The Beatles", "The rolling stones", "Maroon 5", "One Direction", "No Doubt","Black Pink", "EXO", "MonstaX", "Stray Kids","The chainsmokers",]
100+
],
101+
[
102+
r"(.*) actress",
103+
["Scarlett Johansson", "Jennifer Lawrence", "Emma Watson", " Margot Robbie","Angelina Jolie", "Kristen Stewart", "Rachel McAdams","Deepika Padukone", "Priyanka Chopra", "Alia Bhatt", "Kareena Kapoor","Nora Fatehi", "Jacqueline Fernandez", "Aishwarya Rai", "Sara Ali Khan", "Shraddha Kapoor","Anushka Sharma", "Disha Patani",]
104+
],
105+
[
106+
r"(.*) (game|sport)",
107+
["Cricket","Hockey", "Basketball", "Football", "Baseball","Badminton", "Tennis", "Swimming", "Archery","Skates", "Volleyball", "Table Tennis", "Golf",]
108+
],
109+
[
110+
r"(.*) (sports person|player)",
111+
["Lionel Messi","Sania Mirza", "Sachin Tendulkar", "Virat Kohli", "Kevin Durant","Hardik Pandya", "Rohit Sharma", "P. V. Sindhu", "Parupalli Kashyap","Sania Mirza", "Dhyan Chand", "Cristiano Ronaldo", "Robert Lewandowski","Chris Gayle", "Steve Smith", "David Warner", "Ricky Ponting","Stephen Curry", "LeBron James", "M.S.Dhoni", "Chris Paul",]
112+
],
113+
[
114+
r"(.*) actor",
115+
["Robert Downey, Jr.", "Chris Hemsworth", "Tom Holland", "Brad Pitt","Tom Hiddleston", "Tom Cruise", "Chris Evans", "Benedict Cumberbatch","Paul Rudd", "Jeremy Renner", "Ian Somerhalder ","Paul Wesley", "Aamir Khan", "Amitabh Bachchan","Anil Kapoor", "Ranveer Singh", "Ranbir Kapoor", "Salman Khan","Sanjay Dutt", "Shah Rukh Khan", "Tiger Shroff", "Varun Dhawan",]
116+
],
117+
[
118+
r"(.*) dialogue",
119+
["Mere paas maa hai.","Pushpa, I hate tears…","Kitne aadmi the!","Babumoshai, zindagi badi honi chahiye, lambi nahi.","Rishtey mein toh hum tumhare baap lagte hai, naam hai Shahenshaah!","Dosti ka ek usool hai madam – no sorry, no thank you.","Mogambo khush hua!","Hum jahan khade hote hain line yahi se shuru hoti hai.","Bade bade deshon mein aisi choti-choti baatein hoti rehti hai, Senorita.","Haar kar jeetne wale ko baazigar kehte hai.","Mere Karan Arjun aayenge.","Agar maa ka doodh piya hai toh samne aa!","Uska to na bad luck hi kharab hai.","Crime Master Gogo naam hai mera, aankhen nikal ke gotiyan khelta hun main.","Tareekh pe tareekh, tareekh pe tareekh, tareekh pe tareekh milti gayi My Lord, par insaaf nahi mila","Rahul, naam toh suna hi hoga.","Mein apni favourite hoon!","Picture abhi baaki hai mere dost!","How’s the josh?","Thappad se darr nahi lagta sahab, pyaar se lagta hai.","Filmein sirf teen cheezo ke wajah se chalti hai…entertainment, entertainment, entertainment…aur main entertainment hoon.","All izz well",]
120+
],
121+
[
122+
r"quit",
123+
["Bye take care. See you soon :) ","It was nice talking to you. See you soon :)",]
124+
],
125+
[
126+
r"(.*) joke",
127+
["Why did the tomato blush? Because it saw the salad dressing.","What do you call bears with no ears? B","What do dentists call X-rays? Tooth pics.","Did you hear about the first restaurant to open on the moon? It had great food, but no atmosphere.","What did one wall say to the other wall? I’ll meet you at the corner.","When does a joke become a “dad” joke? When the punchline is apparent.","What did the paper say to the pencil? Write on!","How did the bullet lose its job? It got fired.","Why should you never trust stairs? They are always up to something.","Sometimes I tuck my knees into my chest and lean forward.That’s just how I roll.","What do you call a cheese that’s not yours? Nacho cheese!","Did you hear about the cheese factory that exploded in France?There was nothing left but de Brie.",]
128+
],
129+
[
130+
r"even me",
131+
["That's great"]
132+
],
133+
[
134+
r"thank you",
135+
["Your welcome , would you like to know something else if no then please type in QUIT to exit",]
136+
],
137+
]
138+
def chat():
139+
print("Hi! I am Y2K..")
140+
chat = Chat(pairs, reflections)
141+
chat.converse()
142+
143+
#initiate the conversation
144+
if __name__ == "__main__":
145+
chat()

Programs/P01_hello.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Author: OMKAR PATHAK
2+
# This program prints the entered message
3+
4+
def justPrint(text):
5+
'''This function prints the text passed as argument to this function'''
6+
print(text)
7+
8+
if __name__ == '__main__':
9+
justPrint('Hello')

Programs/P02_VariableScope.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#Author: OMKAR PATHAK
2+
#This programs shows the rules for variable scope
3+
4+
# LEGB Rule: Local, Enclosing, Global, Built-in
5+
6+
x = 'Global x'
7+
8+
def test():
9+
#global x
10+
y = 'Local y'
11+
x = 'Local x'
12+
print(x +', '+ y) #prints 'Local x' and 'Local y'
13+
14+
if __name__ == '__main__':
15+
test()
16+
print(x) #prints 'Global x'

Programs/P03_ListsOperations.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#Author: OMKAR PATHAK
2+
#This program gives examples about various list operations
3+
4+
#Syntax: list[start: end: step]
5+
6+
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9]
7+
#index 0 1 2 3 4 5 6 7 8
8+
# -9 -8 -7 -6 -5 -4 -3 -2 -1
9+
10+
#List Slicing
11+
print('Original List:',myList)
12+
print('First Element:',myList[0]) #Prints the first element of the list or 0th element of the list
13+
print('Element at 2nd Index position:',myList[2]) #Prints the 2nd element of the list
14+
print('Elements from 0th Index to 4th Index:',myList[0: 5]) #Prints elements of the list from 0th index to 4th index. IT DOESN'T INCLUDE THE LAST INDEX
15+
print('Element at -7th Index:',myList[-7]) #Prints the -7th or 3rd element of the list
16+
17+
#To append an element to a list
18+
myList.append(10)
19+
print('Append:',myList)
20+
21+
#To find the index of a particular element
22+
print('Index of element \'6\':',myList.index(6)) #returns index of element '6'
23+
24+
#To sort the list
25+
myList.sort()
26+
27+
#To pop last element
28+
print('Poped Element:',myList.pop())
29+
30+
#To remove a particular element from the lsit BY NAME
31+
myList.remove(6)
32+
print('After removing \'6\':',myList)
33+
34+
#To insert an element at a specified Index
35+
myList.insert(5, 6)
36+
print('Inserting \'6\' at 5th index:',myList)
37+
38+
#To count number of occurences of a element in the list
39+
print('No of Occurences of \'1\':',myList.count(1))
40+
41+
#To extend a list that is insert multiple elemets at once at the end of the list
42+
myList.extend([11,0])
43+
print('Extending list:',myList)
44+
45+
#To reverse a list
46+
myList.reverse()
47+
print('Reversed list:',myList)

Programs/P04_Factorial.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#Author: OMKAR PATHAK
2+
#This program finds the favtorial of the specified numbers
3+
#For example, factorial of 5 = 5*4*3*2*1 = 120
4+
5+
def factorial(number):
6+
'''This function finds the factorial of the number passed as argument'''
7+
if number < 0:
8+
print('Invalid entry! Cannot find factorial of a negative number')
9+
if number == 0 or number == 1:
10+
return 1
11+
else:
12+
return number * factorial(number - 1)
13+
14+
if __name__ == '__main__':
15+
userInput = int(input('Enter the Number to find the factorial of: '))
16+
print(factorial(userInput))

Programs/P05_Pattern.py

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#Author: OMKAR PATHAK
2+
#This program prints various patterns
3+
4+
def pattern1(level):
5+
'''This function prints the following pattern:
6+
7+
*
8+
**
9+
***
10+
****
11+
12+
'''
13+
for i in range(1, level + 1):
14+
print()
15+
for j in range(i):
16+
print('*', end = '')
17+
18+
def pattern2(level):
19+
'''This function prints the following pattern:
20+
21+
****
22+
***
23+
**
24+
*
25+
26+
'''
27+
for i in range(level, 0, -1):
28+
print()
29+
for j in range(i):
30+
print('*', end = '')
31+
32+
def pattern3(level):
33+
'''This function prints the following pattern:
34+
35+
*
36+
**
37+
***
38+
****
39+
40+
'''
41+
counter = level
42+
for i in range(level + 1):
43+
print(' ' * counter + '*' * i)
44+
counter -= 1
45+
46+
def pattern4(level):
47+
'''This function prints the following pattern:
48+
49+
****
50+
***
51+
**
52+
*
53+
54+
'''
55+
counter = 0
56+
for i in range(level, 0 ,-1):
57+
print(' ' * counter + '*' * i)
58+
counter += 1
59+
60+
def pattern5(level):
61+
'''This function prints the following pattern:
62+
63+
*
64+
***
65+
*****
66+
67+
'''
68+
# first loop for number of lines
69+
for i in range(level + 1):
70+
#second loop for spaces
71+
for j in range(level - i):
72+
print (" ",end='')
73+
# this loop is for printing stars
74+
for k in range(2 * i - 1):
75+
print("*", end='')
76+
print()
77+
78+
79+
if __name__ == '__main__':
80+
userInput = int(input('Enter the level: '))
81+
pattern1(userInput)
82+
print()
83+
pattern2(userInput)
84+
print()
85+
pattern3(userInput)
86+
print()
87+
pattern4(userInput)
88+
print()
89+
pattern5(userInput)
90+
print()
91+
92+
def pattern6(userInput):
93+
'''
94+
following is the another approach to solve pattern problems with reduced time complexity
95+
96+
for
97+
98+
*
99+
**
100+
***
101+
****
102+
*****
103+
'''
104+
105+
num = int(input('Enter number for pattern'))
106+
pattern = '*'
107+
string = pattern * num
108+
x = 0
109+
110+
for i in string:
111+
x = x + 1
112+
print(string[0:x])

Programs/P06_CharCount.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#Author: OMKAR PATHAK
2+
#This program checks for the character frequency in the given string
3+
4+
def charFrequency(userInput):
5+
'''This fuction helps to count the char frequency in the given string '''
6+
userInput = userInput.lower() #covert to lowercase
7+
dict = {}
8+
for char in userInput:
9+
keys = dict.keys()
10+
if char in keys:
11+
dict[char] += 1
12+
else:
13+
dict[char] = 1
14+
return dict
15+
16+
if __name__ == '__main__':
17+
userInput = str(input('Enter a string: '))
18+
print(charFrequency(userInput))

Programs/P07_PrimeNumber.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#Author: OMKAR PATHAK
2+
#This program checks whether the entered number is prime or not
3+
4+
def checkPrime(number):
5+
'''This function checks for prime number'''
6+
isPrime = False
7+
if number == 2:
8+
print(number, 'is a Prime Number')
9+
if number > 1:
10+
for i in range(2, number):
11+
if number % i == 0:
12+
print(number, 'is not a Prime Number')
13+
isPrime = False
14+
break
15+
else:
16+
isPrime = True
17+
18+
if isPrime:
19+
print(number, 'is a Prime Number')
20+
21+
if __name__ == '__main__':
22+
userInput = int(input('Enter a number to check: '))
23+
checkPrime(userInput)

0 commit comments

Comments
 (0)