Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Day1 Commit * Day1 Commit * Day2 Commit * Day3 Commit * Day5 Commit Until Pattern 3 * Day4 Commit TODO: Part B
- Loading branch information
1 parent
f630bb8
commit d319649
Showing
6 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
''' | ||
* @author: anirudh-jwala | ||
* @date: 12/01/2019 | ||
''' | ||
print("Enter the value of n: ") | ||
n = int(input()) | ||
for i in range(1, n+1): | ||
if i % 3 == 0 and i % 5 == 0: | ||
print("Fizz Buzz") | ||
elif i % 3 == 0: | ||
print("Fizz") | ||
elif i % 5 == 0: | ||
print("Buzz") | ||
else: | ||
print(i) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
''' | ||
* @author: anirudh-jwala | ||
* @date: 12/01/2019 | ||
''' | ||
def reverse(string): | ||
return "".join(reversed(string)) | ||
|
||
print("Enter a string to be reversed: ") | ||
string = input() | ||
print(reverse(string)) | ||
|
||
print() | ||
|
||
print("Palindrome Check") | ||
palindrome = input() | ||
checking_string = reverse(palindrome) | ||
if palindrome == checking_string: | ||
print("Given string is a palindrome") | ||
else: | ||
print("Not a palindrome") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
@author : anirudh-jwala | ||
@date : 12/01/2019 | ||
""" | ||
print("Enter two strings: ") | ||
string1 = input() | ||
string2 = input() | ||
|
||
counter = 0 | ||
|
||
# First we shall be check whether or not they are of same length | ||
|
||
if len(string1) == len(string2): | ||
for i in range(len(string2)): | ||
if string1[i] != string2[i]: | ||
counter += 1 | ||
print("The Hamming Distance between two strings is", counter) | ||
else: | ||
print("We require strings of equal length") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
""" | ||
@author : anirudh-jwala | ||
@date : 12/01/2019 | ||
""" | ||
# Finding no of vowels in given string | ||
|
||
# a e i o u A E I O U are the vowels in English language | ||
|
||
print("String to calculate vowels:") | ||
string = input() | ||
vowels=['a','e','i','o','u', 'A', 'E', 'I', 'O', 'U'] | ||
counter = 0 | ||
|
||
for i in range(len(string)): | ||
if string[i] in vowels: | ||
counter += 1 | ||
|
||
print("No of vowels are ", counter) | ||
|
||
print() | ||
|
||
print("Most frequently frequently character: ") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
@author : anirudh-jwala | ||
@date : 12/01/2019 | ||
""" | ||
|
||
# Pattern 1 | ||
|
||
''' | ||
1 | ||
1 2 | ||
1 2 3 | ||
1 2 3 4 | ||
1 2 3 4 5 | ||
''' | ||
|
||
print("Enter n value") | ||
n = int(input()) | ||
|
||
def pattern1(n): | ||
for i in range(1, n+1): | ||
for j in range(1, i+1): | ||
print(j, end=" ") | ||
print() | ||
|
||
|
||
# Pattern 2 | ||
''' | ||
1 | ||
2 3 | ||
4 5 6 | ||
7 8 9 10 | ||
''' | ||
def pattern2(n): | ||
count = 0 | ||
for i in range(1, n+1): | ||
for j in range(1, i+1): | ||
count += 1 | ||
print(count, end=" ") | ||
print() | ||
|
||
|
||
# Pattern 3 | ||
''' | ||
1 | ||
1 2 | ||
1 2 3 | ||
1 2 3 4 | ||
1 2 3 4 5 | ||
1 2 3 4 | ||
1 2 3 | ||
1 2 | ||
1 | ||
''' | ||
def pattern3(n): | ||
for i in range(1, n+1): | ||
for j in range(1, i+1): | ||
print(j, end=" ") | ||
print() | ||
for i in range(n, 1, -1): | ||
for j in range(1, i): | ||
print(j, end=" ") | ||
print() |