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
24 changes: 24 additions & 0 deletions strings/check_panagram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Created by sarathkaul on 12/11/19


def check_panagram(input_str: str) -> None:
"""
A Panagram String contains all the alphabets at least once.
>>> check_panagram("The quick brown fox jumps over the lazy dog")
The quick brown fox jumps over the lazy dog is a Panagram String
>>> check_panagram("My name is Unknown")
My name is Unknown is not a Panagram String
"""
frequency = set()

for alpha in input_str:
if alpha != " ":
frequency.add(alpha.lower())
if len(frequency) == 26:
print(f"{input_str} is a Panagram String")
else:
print(f"{input_str} is not a Panagram String")


if __name__ == "main":
check_panagram("INPUT 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>")
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>")