From 81c42d64ff9d245df91004709f6353f493aac4f4 Mon Sep 17 00:00:00 2001 From: Anisha Sawant Date: Thu, 28 Oct 2021 11:51:11 +0530 Subject: [PATCH] Added files in Python --- python/Akhbar padhke sunao.py | 25 +++++++++++++++++++++++++ python/Know Your age in 2090.py | 29 +++++++++++++++++++++++++++++ python/The next palindrome.py | 21 +++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 python/Akhbar padhke sunao.py create mode 100644 python/Know Your age in 2090.py create mode 100644 python/The next palindrome.py diff --git a/python/Akhbar padhke sunao.py b/python/Akhbar padhke sunao.py new file mode 100644 index 0000000..4bb57b0 --- /dev/null +++ b/python/Akhbar padhke sunao.py @@ -0,0 +1,25 @@ +import json +import requests + +def speak(str): + from win32com.client import Dispatch + speak = Dispatch("SAPI.SpVoice") + speak.Speak(str) + +# speak("News for today") + +if __name__=='__main__': + # speak("News for today") + url="http://newsapi.org/v2/top-headlines?country=in&apiKey=47c2ca33ecd24419b753c88a9df9330d" + r=requests.get(url).text + # print(r) + data=json.loads(r) + print(data["articles"]) + arts=(data["articles"]) + # for article in arts: + # speak(article['title']) + # speak("Next news is") + for i in arts: + speak(i["title"]) + speak("Next news is") + diff --git a/python/Know Your age in 2090.py b/python/Know Your age in 2090.py new file mode 100644 index 0000000..5e84d81 --- /dev/null +++ b/python/Know Your age in 2090.py @@ -0,0 +1,29 @@ +while(True): + i=int(input("Enter your age or Birth Year(YYYY): ")) + + if(len(str(i))==4): + if(1920<=i<=2021): + print("Your age in 2090 will be ",(2090-i)) + + elif(i>2022): + print("You are not born yet !") + + else: + print("You seem to be the oldest person alive") + + else: + if(0<=i<=120): + print("Your age in 2090 will be ",(2090-(2021-i))) + elif(i<0): + print("You are not born yet") + else: + print("You seem to be oldest person alive.") + + # print("Do you want to continue? 1 or 0") + # ch=input() + # if ch==1: + # continue + # else: + # break + +pr \ No newline at end of file diff --git a/python/The next palindrome.py b/python/The next palindrome.py new file mode 100644 index 0000000..1c0bb84 --- /dev/null +++ b/python/The next palindrome.py @@ -0,0 +1,21 @@ +def rev_item(p): + rem=0 + num=0 + while p>0: + rem=(rem*10)+(p%10) + num=rem + p=p//10 + return(num) + +n=int(input("Number of test cases you want: ")) +for i in range(n): + t=int(input("Enter a number:")) + if t==rev_item(t): + print(f"{t} itself is a palindrome") + else: + for i in range(t+1,t+100): + + if (rev_item(i)==i): + print(f"Next palindrome of {t} is {rev_item(i)}") + break +exit()