Skip to content

Commit b05c96d

Browse files
committed
Day4 added
1 parent fbdc33f commit b05c96d

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed

Day4/anagrams.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Program 2: Anagrams
3+
Input : s1 = "luffy"
4+
s2 = "fufly"
5+
Output : Pair of words are anagrams
6+
7+
Sample Input : s1 = "luffy"
8+
s2 = "naruto"
9+
Sample Output : Not a anagrams
10+
11+
Sample Input : s1 = "bad"
12+
s2 = "dad"
13+
Sample Output : Not a anagrams
14+
15+
Sample Input : s1 = "cool"
16+
s2 = "loco"
17+
Sample Output : Pair of words are anagrams
18+
"""
19+
word1=input("Enter first string:").lower()
20+
word2=input("Enter second string:").lower()
21+
if(sorted(word1)==sorted(word2)):
22+
print('Pair of words are anagrams')
23+
else:
24+
print('Not a anagrams')

Day4/palindrome.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Program 1: Palindrome
2+
Malayalam, madam, civic. Now why am I mentioning this words. Palindrome are
3+
those words which are pronounced the same even if you read them in reverse
4+
way. The word is Palindrome if it is equal to the reverse of the word.
5+
Sample Input: madam
6+
the reverse of the word is also madam
7+
Thus it is a Palindrome
8+
Sample Input: professor
9+
the reverse of the word is also rosseforp
10+
Thus it is not a Palindrome
11+
"""
12+
palindrome = input("Enter a word: ")
13+
reverse = palindrome[::-1]
14+
if reverse == palindrome:
15+
print("Yes it is a Palindrome")
16+
else:
17+
print("No it is not a Palindrome")

Day4/password.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Program 5: Strong or Weak password
3+
Let a user enter a password you just have to print Strong or weak, and nothing
4+
else.
5+
A password is said to be strong:
6+
 If password should at-least be 8 letters long
7+
 Password must contain at least one upper case characters [A-Z]
8+
 Password must contain at least 2 numbers [0-9]
9+
 Password must contain at least one 1 special symbol [.,%$#@!^&*():"]
10+
If the above criteria as meet then print Strong, else Weak.
11+
Sample Input: password?!123
12+
Sample Output: Weak [because no upper case character]
13+
Sample Input: LuffyKing&100
14+
Sample Output: Strong
15+
"""
16+
import string
17+
import sys
18+
password = input("Enter your password:")
19+
if len(password)<8:
20+
print("Weak")
21+
sys.exit()
22+
23+
numbers,upper_case,symbol = 0,0,0
24+
for check in password:
25+
if check in string.ascii_uppercase:
26+
upper_case+=1
27+
elif check in string.punctuation:
28+
symbol+=1
29+
elif check in string.digits:
30+
numbers+=1
31+
else:
32+
pass
33+
34+
if upper_case>=1 and numbers>=2 and symbol>=1:
35+
print("Strong")
36+
else:
37+
print("Weak")

Day4/secret.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
Program 4: Secret Message
3+
A string of your message in its normal form. Ask user for a input and convert that
4+
message into a secret message. The way you should do this is, say the message is
5+
converted based on backwards alphabets i.e., a is replaced with z, a=z, b=y, c=x,
6+
d=w, e=v, f=u, g=t and so on..
7+
Output Format:
8+
A string of your message once you have encoded it (all lower case).
9+
Sample Input: Pirate King
10+
Sample Output: krizgv prmt
11+
Explanation:
12+
If you replace each letter in 'Pirate King' with the corresponding letter in a
13+
backwards version of the alphabet, you get 'krizgv prmt'.
14+
"""
15+
16+
import string
17+
user_data = input().lower()
18+
backwards = string.ascii_lowercase[::-1]
19+
back_alpha = ''
20+
for alpha in user_data:
21+
if alpha == ' ':
22+
back_alpha+=' '
23+
else:
24+
index = string.ascii_lowercase.index(alpha)
25+
back_alpha+=backwards[index]
26+
print(back_alpha)

Day4/tax.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name=input("Enter your name: ")
2+
age=int(input('Enter your age:'))
3+
while True:
4+
gender=input('Enter M for male and F for Female:').lower()
5+
if gender not in 'm f':
6+
continue
7+
else:
8+
break
9+
10+
if(age>=65 or gender.startswith('f')):
11+
tax='Nile'
12+
if(age<=65 and gender.startswith('m')):
13+
tax_amt=int(input('Enter your Taxable Income: '))
14+
if tax_amt<0 or tax_amt in range(0,16001):
15+
tax=0
16+
elif tax_amt in range(160001,500001):
17+
tax=(tax_amt-160000)*0.1
18+
elif tax_amt in range(500001,800001):
19+
tax=((tax_amt-500000)*0.2)+34000
20+
elif(tax_amt>800000):
21+
tax=((tax_amt-160000)*0.3)+94000
22+
print('Tax to be paid',tax)

0 commit comments

Comments
 (0)