Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Twitter Automation Code Added #168

Merged
merged 3 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 155 additions & 125 deletions Basic-Scripts/Simple_calculator.py
Original file line number Diff line number Diff line change
@@ -1,125 +1,155 @@


"""The previous script becomes very boring for the user as he has to keep on typing just numbers and of wants to interact using
simple english language he is unable to do so. Also the program terminates after one execution and if the user wants to keep on
performing operations it becomes difficult.
I have tried making a more simple and interactive calculator which allows the user to input any statement for performing the tasks. """




def Calculator(num_1,num_2):
#Executing the loop infinite times as we donot know how many times the user will want to run
while(True):
choice= input("Enter what you want to perform: ")
print()

#For Addition user can type any Sentence containing word related to it and will get the output but here we are checking only for the common words
if ("addition" in choice) or ("add" in choice) or ("sum" in choice) or ("plus" in choice):
sum = (num_1) + (num_2)
print("Output....")
print("Adding {} and {} results to {}".format(num_1,num_2,sum))
print()

#For Subtraction user can type any Sentence containing word related to it and will get the output but here we are checking only for the common words
elif ("subtraction" in choice) or ("minus" in choice) or ("difference" in choice) or ("subtract" in choice):
if( num_1 > num_2 ):
diff = (num_1) - (num_2)
print("Output....")
print("Subtracting {} from {} results to {}".format(num_2,num_1,diff))
print()
elif( num_2 > num_1 ):
diff = (num_2) - (num_1)
print("Output....")
print("Subtracting {} from {} results to {}".format(num_1,num_2,diff))
print()

#For Multiplication user can type any Sentence cpntaining word related to it and will get the output but here we are checking only for the common words
elif ("multiplication" in choice) or ("product" in choice) or ("multiply" in choice):
if(num_1==0 or num_2==0):
print("Output....")
print("Multiplying {} and {} results to 0".format(num_1,num_2))
print()
elif(num_1==1):
print("Output....")
print("Multiplying {} and {} results to {}".format(num_1,num_2,num_2))
print()
elif(num_2==1):
print("Output....")
print("Multiplying {} and {} results to {}".format(num_1,num_2,num_1))
print()
else:
mul = (num_1) * (num_2)
print("Output....")
print("Multiplying {} and {} results to {}".format(num_1,num_2,mul))
print()

#For Division user can type any Sentence cpntaining word related to it and will get the output but here we are checking only for the common words
elif("division" in choice) or ("divide" in choice) or ("quotient" in choice):
if( num_1 > num_2 ):
if(num_2==0):
print("Output....")
print("Error: Please try with some other values!")

elif(num_1==0):
print("Output....")
print("Dividing {} from {} results to 0".format(num_1,num_2))
print()
else:
div = (num_1) / (num_2)
print("Output....")
print("Dividing {} from {} results to {}".format(num_1,num_2,div))
print()
elif(num_1==0 and num_2==0):
print("Infinity!")
print()
elif( num_2 > num_1 ):
if(num_1==0):
print("Output....")
print("Error: Please try with some other values!")
print()

elif(num_2==0):
print("Output....")
print("Dividing {} from {} results to 0".format(num_1,num_2))
print()
else:
div = (num_2) / (num_1)
print("Output....")
print("Dividing {} from {} results to {}".format(num_2,num_1,div))
print()

#For exiting the loop user can type any Sentence containing word related to it and it will exit from the loop but here we are checking for the common words
elif ("exit" in choice) or ("stop" in choice) or ("return" in choice):
break

else:
print()
print("Operation not found: Please try again!")
print()



def main():

print()
print(" THIS IS A BASIC USER FRIENDLY CALCULATOR! ")
print()
print("You can type a sentence and interact.")
print()
#inputting two numbers at a time using the split function
num_1,num_2 = input("Enter two numbers: ").split()
num1=float(num_1)
num2=float(num_2)


#printing both the numbers
print("Number 1 is: ",num_1)
print("Number 2 is: ",num_2)
print()

Calculator(num_1,num_2)


if __name__ == "__main__":
main()
operation = input('''
Please type in the math operation you would like to complete:
1 for addition
2 for subtraction
3 for multiplication
4 for division
''')

num = int(input('Enter your first number: '))
num2 = int(input('Enter your second number: '))

if operation == '1':
print('{} + {} = '.format(num, num2))
print(num+num2)

elif operation == '2':
print('{} - {} = '.format(num, num2))
print(num-num2)

elif operation == '3':
print('{} * {} = '.format(num, num2))
print(num*num2)

elif operation == '4':
print('{} / {} = '.format(num, num2))
print(num / num2)

else:
print('Wrong Input! Please Try Again')
=======


"""The previous script becomes very boring for the user as he has to keep on typing just numbers and of wants to interact using
simple english language he is unable to do so. Also the program terminates after one execution and if the user wants to keep on
performing operations it becomes difficult.
I have tried making a more simple and interactive calculator which allows the user to input any statement for performing the tasks. """




def Calculator(num_1,num_2):
#Executing the loop infinite times as we donot know how many times the user will want to run
while(True):
choice= input("Enter what you want to perform: ")
print()

#For Addition user can type any Sentence containing word related to it and will get the output but here we are checking only for the common words
if ("addition" in choice) or ("add" in choice) or ("sum" in choice) or ("plus" in choice):
sum = (num_1) + (num_2)
print("Output....")
print("Adding {} and {} results to {}".format(num_1,num_2,sum))
print()

#For Subtraction user can type any Sentence containing word related to it and will get the output but here we are checking only for the common words
elif ("subtraction" in choice) or ("minus" in choice) or ("difference" in choice) or ("subtract" in choice):
if( num_1 > num_2 ):
diff = (num_1) - (num_2)
print("Output....")
print("Subtracting {} from {} results to {}".format(num_2,num_1,diff))
print()
elif( num_2 > num_1 ):
diff = (num_2) - (num_1)
print("Output....")
print("Subtracting {} from {} results to {}".format(num_1,num_2,diff))
print()

#For Multiplication user can type any Sentence cpntaining word related to it and will get the output but here we are checking only for the common words
elif ("multiplication" in choice) or ("product" in choice) or ("multiply" in choice):
if(num_1==0 or num_2==0):
print("Output....")
print("Multiplying {} and {} results to 0".format(num_1,num_2))
print()
elif(num_1==1):
print("Output....")
print("Multiplying {} and {} results to {}".format(num_1,num_2,num_2))
print()
elif(num_2==1):
print("Output....")
print("Multiplying {} and {} results to {}".format(num_1,num_2,num_1))
print()
else:
mul = (num_1) * (num_2)
print("Output....")
print("Multiplying {} and {} results to {}".format(num_1,num_2,mul))
print()

#For Division user can type any Sentence cpntaining word related to it and will get the output but here we are checking only for the common words
elif("division" in choice) or ("divide" in choice) or ("quotient" in choice):
if( num_1 > num_2 ):
if(num_2==0):
print("Output....")
print("Error: Please try with some other values!")

elif(num_1==0):
print("Output....")
print("Dividing {} from {} results to 0".format(num_1,num_2))
print()
else:
div = (num_1) / (num_2)
print("Output....")
print("Dividing {} from {} results to {}".format(num_1,num_2,div))
print()
elif(num_1==0 and num_2==0):
print("Infinity!")
print()
elif( num_2 > num_1 ):
if(num_1==0):
print("Output....")
print("Error: Please try with some other values!")
print()

elif(num_2==0):
print("Output....")
print("Dividing {} from {} results to 0".format(num_1,num_2))
print()
else:
div = (num_2) / (num_1)
print("Output....")
print("Dividing {} from {} results to {}".format(num_2,num_1,div))
print()

#For exiting the loop user can type any Sentence containing word related to it and it will exit from the loop but here we are checking for the common words
elif ("exit" in choice) or ("stop" in choice) or ("return" in choice):
break

else:
print()
print("Operation not found: Please try again!")
print()



def main():

print()
print(" THIS IS A BASIC USER FRIENDLY CALCULATOR! ")
print()
print("You can type a sentence and interact.")
print()
#inputting two numbers at a time using the split function
num_1,num_2 = input("Enter two numbers: ").split()
num1=float(num_1)
num2=float(num_2)


#printing both the numbers
print("Number 1 is: ",num_1)
print("Number 2 is: ",num_2)
print()

Calculator(num_1,num_2)


if __name__ == "__main__":
main()
Empty file added Basic-Scripts/tic-tac-toe.py
Empty file.
7 changes: 6 additions & 1 deletion Contribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@
- Fork the [repository](https://github.com/ankitdobhal/Awesome-Python-Scripts)

- Clone the fork [repo](https://github.com/ankitdobhal/Awesome-Python-Scripts)
- git clone https://github.com/ankitdobhal/Awesome-Python-Scripts

- git clone https://github.com/<Your_Username>/Awesome-Python-Scripts
- Create new branch
- Create new branch
- git checkout -b <Your-Branch-Name>

- Add Scripts related to your respective issues.
- git add <your-contribution>

- Add a commit message !
- git commit -a -m "<Added your message>"
- Push changes
- git push origin


- Push changes
- git push -u origin <name_of_your_branch>
Expand Down
32 changes: 32 additions & 0 deletions System-Automation-Scripts/Twitter Automation/Twitter Automation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@


#Importing Library
import tweepy
import time

#Twitter Authentication APIs
CONSUMER_KEY = '<enter-your-consumer-key>'
CONSUMER_SECRET = '<enter-your-consumer-secret-key>'
ACCESS_KEY = '<enter-your-access-key>'
ACCESS_SECRET = '<enter-your-access-secret-key>'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

#Likes & Retweeting
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
user = api.me()
search = '#india'
numTweet = 500
for tweet in tweepy.Cursor(api.search, search).items(numTweet):
try:
print('Tweet Liked') #Like
tweet.favorite()
print("Retweet done") #Retweet
tweet.retweet()
time.sleep(10)
except tweepy.TweepError as e:
print(e.reason)
except StopIteration:
break

##Press 'i' to stop iteration in jupyter notebook