Skip to content

Commit

Permalink
Added python programs in day4 (#47)
Browse files Browse the repository at this point in the history
* Add @prateek3255 as a contributor

* Added python solutions in day 4 and updated readme
  • Loading branch information
prateek3255 authored and MadhavBahl committed Dec 25, 2018
1 parent 59b8bd3 commit 64de4be
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .all-contributorsrc
Expand Up @@ -133,6 +133,16 @@
"code",
"doc"
]
},
{
"login": "prateek3255",
"name": "Prateek Surana",
"avatar_url": "https://avatars3.githubusercontent.com/u/21277179?v=4",
"profile": "http://prateeksurana.me",
"contributions": [
"doc",
"code"
]
}
]
}
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
@@ -1,4 +1,4 @@
[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors)
## Contributors

Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
Expand All @@ -7,7 +7,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
<!-- prettier-ignore -->
| [<img src="https://avatars2.githubusercontent.com/u/26179770?v=4" width="100px;"/><br /><sub><b>MADHAV BAHL</b></sub>](http://madhavbahl.tech/)<br />[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=MadhavBahlMD "Code") [📝](#blog-MadhavBahlMD "Blogposts") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=MadhavBahlMD "Documentation") [🎨](#design-MadhavBahlMD "Design") [✅](#tutorial-MadhavBahlMD "Tutorials") | [<img src="https://avatars2.githubusercontent.com/u/32531173?v=4" width="100px;"/><br /><sub><b>Rajdeep Roy Chowdhury</b></sub>](http://www.linkedin.com/in/razdeeproychowdhury)<br />[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Razdeep "Code") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Razdeep "Documentation") [✅](#tutorial-Razdeep "Tutorials") | [<img src="https://avatars1.githubusercontent.com/u/16208722?v=4" width="100px;"/><br /><sub><b>Hrishi</b></sub>](https://hrishi1999.github.io)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Hrishi1999 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Hrishi1999 "Code") | [<img src="https://avatars1.githubusercontent.com/u/33101287?v=4" width="100px;"/><br /><sub><b>Bhanu Ailani</b></sub>](https://github.com/Bhanu0202)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Bhanu0202 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Bhanu0202 "Code") | [<img src="https://avatars3.githubusercontent.com/u/35690440?v=4" width="100px;"/><br /><sub><b>Deepak Sharma</b></sub>](https://sourcerer.io/dsdsharma)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dsdsharma "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dsdsharma "Code") | [<img src="https://avatars2.githubusercontent.com/u/28749866?v=4" width="100px;"/><br /><sub><b>Ramanpreet Singh</b></sub>](https://github.com/Ramanpreet6262)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Ramanpreet6262 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Ramanpreet6262 "Code") | [<img src="https://avatars1.githubusercontent.com/u/27620628?v=4" width="100px;"/><br /><sub><b>Anil Khatri</b></sub>](https://imkaka.github.io/)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=imkaka "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=imkaka "Code") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars0.githubusercontent.com/u/39827514?v=4" width="100px;"/><br /><sub><b>Ashwek Swamy</b></sub>](https://github.com/ashwek)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Code") | [<img src="https://avatars1.githubusercontent.com/u/32368107?v=4" width="100px;"/><br /><sub><b>Dhruv Gupta</b></sub>](https://github.com/dhruv-gupta14)<br />[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dhruv-gupta14 "Code") | [<img src="https://avatars0.githubusercontent.com/u/30969577?v=4" width="100px;"/><br /><sub><b>Aadit Kamat</b></sub>](https://sg.linkedin.com/in/aadit-kamat-12a5a8140)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Code") | [<img src="https://avatars1.githubusercontent.com/u/20285786?v=4" width="100px;"/><br /><sub><b>Shashank jain</b></sub>](http://www.myshashank.tech)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Code") | [<img src="https://avatars3.githubusercontent.com/u/22260031?v=4" width="100px;"/><br /><sub><b>Moulik Aggarwal</b></sub>](https://github.com/moulikcipherX)<br />[💬](#question-moulikcipherX "Answering Questions") [📝](#blog-moulikcipherX "Blogposts") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Code") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Documentation") |
| [<img src="https://avatars0.githubusercontent.com/u/39827514?v=4" width="100px;"/><br /><sub><b>Ashwek Swamy</b></sub>](https://github.com/ashwek)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Code") | [<img src="https://avatars1.githubusercontent.com/u/32368107?v=4" width="100px;"/><br /><sub><b>Dhruv Gupta</b></sub>](https://github.com/dhruv-gupta14)<br />[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dhruv-gupta14 "Code") | [<img src="https://avatars0.githubusercontent.com/u/30969577?v=4" width="100px;"/><br /><sub><b>Aadit Kamat</b></sub>](https://sg.linkedin.com/in/aadit-kamat-12a5a8140)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Code") | [<img src="https://avatars1.githubusercontent.com/u/20285786?v=4" width="100px;"/><br /><sub><b>Shashank jain</b></sub>](http://www.myshashank.tech)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Code") | [<img src="https://avatars3.githubusercontent.com/u/22260031?v=4" width="100px;"/><br /><sub><b>Moulik Aggarwal</b></sub>](https://github.com/moulikcipherX)<br />[💬](#question-moulikcipherX "Answering Questions") [📝](#blog-moulikcipherX "Blogposts") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Code") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/21277179?v=4" width="100px;"/><br /><sub><b>Prateek Surana</b></sub>](http://prateeksurana.me)<br />[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=prateek3255 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=prateek3255 "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
15 changes: 15 additions & 0 deletions day4/Python/partA_sol.py
@@ -0,0 +1,15 @@
'''
* @author: prateek3255
* @date: 25/12/2018
'''

string=input("Enter the String : ")
vowels=['a','e','i','o','u']

count=0

for char in string:
if char.lower() in vowels:
count+=1

print("Number of vowels in the string are : ",count)
15 changes: 15 additions & 0 deletions day4/Python/partB_sol.py
@@ -0,0 +1,15 @@
'''
* @author: prateek3255
* @date: 25/12/18
'''

string=input("Enter the string : ")
characters={}

for char in string:
if char.lower() in characters:
characters[char.lower()]+=1
else:
characters[char.lower()]=1

print("The most occouring character in the string is : ", max(characters,key=characters.get))
55 changes: 54 additions & 1 deletion day4/README.md
Expand Up @@ -137,7 +137,7 @@ numVowels ('hello');
numVowels ('Greetings');
```

## Java Implementatio
## Java Implementation

### [Solution 1](./Java/NumVowels.java)

Expand Down Expand Up @@ -214,6 +214,31 @@ public class NumVowels2 {
System.out.println("Number of vowels in \"" + str + "\" = " + count);
}
}
```
## Python Implementation

### [Solution](./Python/partA_sol.py)

```python
# Input the String.
string=input("Enter the String : ")

# Create a list of vowels in lowercase.
vowels=['a','e','i','o','u']

# Initialize the count variable to zero.
count=0

# Now iterate every character in the string.
for char in string:
# And if the current character we are iterating is
# present in the vowels list then increment count.
if char.lower() in vowels:
count+=1

# Print the result
print("Number of vowels in the string are : ",count)

```

<hr/>
Expand Down Expand Up @@ -291,3 +316,31 @@ function maxChars (sentence) {

maxChars('helllllo worlld');
```
## Python Implementation

### [Solution](./Python/partB_sol.py)

```python
# Input the string
string=input("Enter the string : ")

# Create an empty dictionary to store the frequency of characters
characters={}

# Iterate every character in the string
for char in string:
# And if the character already exists in the dictionary then
# increment its frequency by 1.
if char.lower() in characters:
characters[char.lower()]+=1
# Else initialize its frequency by 1
else:
characters[char.lower()]=1

# Print the character which has the maximum frequency
print("The most occouring character in the string is : ", max(characters,key=characters.get))

```



0 comments on commit 64de4be

Please sign in to comment.