Skip to content

Panagram Script Added #1564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 14, 2019
Merged
30 changes: 30 additions & 0 deletions strings/check_panagram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Created by sarathkaul on 12/11/19


def check_panagram(
input_str: str = "The quick brown fox jumps over the lazy dog",
) -> bool:
"""
A Panagram String contains all the alphabets at least once.
>>> check_panagram("The quick brown fox jumps over the lazy dog")
True
>>> check_panagram("My name is Unknown")
False
>>> check_panagram("The quick brown fox jumps over the la_y dog")
False
"""
frequency = set()
input_str = input_str.replace(
" ", ""
) # Replacing all the Whitespaces in our sentence
for alpha in input_str:
if "a" <= alpha.lower() <= "z":
frequency.add(alpha.lower())

return True if len(frequency) == 26 else False


if __name__ == "main":
check_str = "INPUT STRING"
status = check_panagram(check_str)
print(f"{check_str} is {'not ' if status else ''}a panagram string")
3 changes: 1 addition & 2 deletions web_programming/fetch_bbc_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import requests

# Enter Your API Key in following URL
_NEWS_API = "https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey="


Expand All @@ -14,5 +13,5 @@ def fetch_bbc_news(bbc_news_api_key: str) -> None:
print(f"{i}.) {article['title']}")


if __name__ == '__main__':
if __name__ == "__main__":
fetch_bbc_news(bbc_news_api_key="<Your BBC News API key goes here>")
17 changes: 17 additions & 0 deletions web_programming/fetch_github_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Created by sarathkaul on 14/11/19

import requests

_GITHUB_API = "https://api.github.com/user"


def fetch_github_info(auth_user: str, auth_pass: str) -> None:
# fetching github info using requests
info = requests.get(_GITHUB_API, auth=(auth_user, auth_pass))

for a_info, a_detail in info.json().items():
print(f"{a_info}: {a_detail}")


if __name__ == "main":
fetch_github_info("<USER NAME>", "<PASSWORD>")
18 changes: 18 additions & 0 deletions web_programming/slack_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Created by sarathkaul on 12/11/19

import requests


def send_slack_message(message_body: str, slack_url: str) -> None:
headers = {"Content-Type": "application/json"}
response = requests.post(slack_url, json={"text": message_body}, headers=headers)
if response.status_code != 200:
raise ValueError(
f"Request to slack returned an error {response.status_code}, "
f"the response is:\n{response.text}"
)


if __name__ == "main":
# Set the slack url to the one provided by Slack when you create the webhook at https://my.slack.com/services/new/incoming-webhook/
send_slack_message("<YOUR MESSAGE BODY>", "<SLACK CHANNEL URL>")