Skip to content

Commit 1642895

Browse files
committed
Day6 added
1 parent 2467ec1 commit 1642895

File tree

4 files changed

+143
-0
lines changed

4 files changed

+143
-0
lines changed

Day6/mall_shopping.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
Imagine your in a Mall for Shopping, you come across a store that serves good food. The Menu is displayed to you, you decide the food you like and add it in cart. Once you decided your meal, you now need to order and pay the amount for you meal. And at end display a Thank You message.
3+
"""
4+
import termcolor
5+
def display_menu():
6+
menu = {
7+
"Papad Salad":60,
8+
"Manchurian Soup":100,
9+
"Jalebi And Fafda":150,
10+
"Baby-Corn Machuri":85,
11+
"Paneer Tikka":100,
12+
"Hamburger":120,
13+
"Double Cheese Decker Pizza":199,
14+
"Butter Kulcha":45,
15+
"Roti":30,
16+
"Malai Kofta":100,
17+
"Dal Fry":80,
18+
"Fried Rice":140,
19+
"Death By Chocolate Desert":200,
20+
"Hot Chocolate":180
21+
}
22+
23+
termcolor.cprint("\n\t****Welcome To Anime Vyuh Foods****\t\n",color="red")
24+
termcolor.cprint("\n\tHere is the Menu:\n\n",color="yellow")
25+
for food,price in menu.items():
26+
termcolor.cprint("{} {} :{}INR".format(food,''*20,price),"blue")
27+
28+
return menu
29+
30+
course_menu = display_menu()
31+
cart = []
32+
print("What could you like to eat? Enter the name from the menu")
33+
while True:
34+
eat = input("\nAdd Food Name?(q to quit):")
35+
if eat.lower().startswith('q'):
36+
break
37+
if eat not in course_menu.keys():
38+
print("Invalid Entry! Check the Spelling and Try again:")
39+
else:
40+
print(eat,"added to eat list.")
41+
cart.append(eat)
42+
43+
print("The Amount To Be Paid:",end="")
44+
amt = 0
45+
for i in cart:
46+
amt=amt+course_menu[i]
47+
48+
print(" {} INR\n".format(float(amt)))
49+
print("Thank You For Visiting Us")

Day6/numeral.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Input Format:
3+
A string of the phrase in its original form (lowercase).
4+
5+
Output Format:
6+
A string of the updated phrase that has changed the numerals to words.
7+
Sample Input: I need 2 pumpkins and 3 apples
8+
9+
Sample Output: I need two pumpkins and three apples
10+
"""
11+
12+
def numeral(num,n):
13+
nonum=dict()
14+
for i in n:
15+
nonum[str(i)]=num[i-1]
16+
return(nonum)
17+
18+
num=['one','two','three','four','five','six','seven','eight','nine','ten']
19+
n=range(1,11)
20+
nonumeral=numeral(num,n)
21+
data=input('').split()
22+
new_data=[]
23+
for word in data:
24+
if word in nonumeral.keys():
25+
word=nonumeral[word]
26+
new_data.append(word)
27+
print(' '.join(new_data))

Day6/phonebook.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
phonebook = dict()
2+
3+
def is_valid(number,name):
4+
# check for valid name and number
5+
# observe we have used if else in single statement
6+
# number should be exactly 10 digit & name should be >3 letters
7+
response = True if len(number)==10 and number.isdigit() and len(name)>=3 else False
8+
return response
9+
10+
def keep_searching():
11+
while True:
12+
#ask user if he wants to continue or quit
13+
move = input("Do you want to continue(c) or quit(q)?").lower()
14+
if move not in ['c','q']: #if user enters other than c or q
15+
print("Enter c to continue or q to quit: ")
16+
continue
17+
else:
18+
if move.startswith('c'):
19+
return True
20+
return False
21+
22+
while True:
23+
name = input("Enter your name:").lower()
24+
phone_number = input("Enter your number:")
25+
if is_valid(phone_number,name):
26+
phonebook[name]=phone_number
27+
else:
28+
print("Invalid Entry..")
29+
continue
30+
31+
print("Look Into PhoneBook")
32+
search_name = input("Search the name in the Phonebook: ").lower()
33+
if search_name in phonebook:
34+
print(search_name,"number is",phonebook[search_name])
35+
else:
36+
avaiable = input("Name and number not stored, Do you want add it?(Y/n):").lower()
37+
if avaiable.startswith('y'):
38+
new_number = input("Enter the number to be stored: ")
39+
if is_valid(new_number,search_name):
40+
phone_number[search_name]=new_number
41+
else:
42+
print("Failed to Update")
43+
44+
if keep_searching():
45+
continue
46+
else:
47+
print("Thank you for visiting..")
48+
break

Day6/word_frequency_counter.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import string
2+
3+
def remove_punction(para):
4+
new = ""
5+
for i in para:
6+
if i in string.punctuation:
7+
pass
8+
else:
9+
new+=i
10+
return new
11+
12+
sample_input = input("Enter a sentence:")
13+
word_dictionary = dict() # or {}
14+
sentence = remove_punction(sample_input)
15+
16+
for word in sentence.split():
17+
word_dictionary[word] = 1 if word not in word_dictionary else word_dictionary[word]+1
18+
19+
print(word_dictionary)

0 commit comments

Comments
 (0)