Learn Python like a Professional! Take You from 0 to Hero
In this Python lecture, we will learn about the Q&A 7th
Q. Write the Program to count the occurrence of a number in the digit given by the user
Example:
111122233333
Output:
1 occur 4-times
2 occur 3-times
3 occur 5-times
num=input('Enter the digit =')
from collections import Counter
for key,value in Counter(list(num)).items(): print('{x} occur {y}-times'.format(x=key,y=value))
>>1 occur 4-times
2 occur 3-times
3 occur 5-times
2 occur 3-times
3 occur 5-times
Q. Write a program to remove the punctuation marks from the string given by the user
Example: Hi guys, welcome back to python ninja bootcamp. Let's get started!
Output: Hi guys welcome back to python ninja bootcamp Let s get started
import re
pattern='\w+'
string=input('Enter the string = ')
' '.join(re.findall(pattern,string))
Q.Write a program to extract the Email id from the string given by the user.
Example: Please contact sn.gurukul24.7uk@gmail.com for assistance
Output: sn.gurukul24.7uk@ gmail.com
import re
pattern='[\w\.-]+@[\w\.-]+' #[\w\.-]+ matches one or more aplha numeric, dot or dash
string=input('Enter the string = ')
re.search(pattern,string).group()
EDITS ARE WELCOMED!!
In the next Blog, we will discuss Free Python Certification
https://sngurukuls247.blogspot.com/2019/01/free-python-certification-online.html
......................................................................................................................................
Instagram-
https://www.instagram.com/python.india/
View the Jupyter Notebook for this lecture
Download the Jupyter Notebook for this lecture
https://sngurukuls247.blogspot.com/2019/01/free-python-certification-online.html
......................................................................................................................................
Follow the link below to access Free Python Lectures-
https://www.youtube.com/channel/UCENc9qI7_r8KMf6-_1R1xnwInstagram-
https://www.instagram.com/python.india/
View the Jupyter Notebook for this lecture
Feel free contact me on-
Email - sn.gurukul24.7uk@gmail.com
No comments:
Post a Comment