Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import time
- import math
- import subprocess as sp
- import json
- import urllib
- import platform
- import sys
- import smtplib
- os = platform.system()
- pcname = platform.node()
- def main():
- cls()
- print("1) Calculator")
- print("2) IP Tools")
- print("3) Binary")
- sin = input('>>> ')
- if sin == 1:
- calc()
- if sin == 2:
- ipt()
- if sin == 3:
- bint()
- def calc():
- def add():
- cls()
- print("Type Number 1")
- n1 = input(">>> ")
- print("Type Number 2")
- n2 = input(">>> ")
- tot = n1+n2
- print(str(n1)+" + "+str(n2)+" = "+str(tot))
- def sub():
- cls()
- print("Type Number 1")
- n1 = input(">>> ")
- print("Type Number 2")
- n2 = input(">>> ")
- tot = n1-n2
- print(str(n1)+" - "+str(n2)+" = "+str(tot))
- def mul():
- cls()
- print("Type Number 1")
- n1 = input(">>> ")
- print("Type Number 2")
- n2 = input(">>> ")
- tot = n1*n2
- print(str(n1)+" x "+str(n2)+" = "+str(tot))
- def div():
- cls()
- print("Type Number 1")
- n1 = input(">>> ")
- print("Type Number 2")
- n2 = input(">>> ")
- tot = n1/n2
- r = n1%n2
- print(str(n1)+" / "+str(n2)+" = "+str(tot)+" R"+str(r))
- cls()
- print '1) Addition'
- print '2) Subtraction'
- print '3) Multiplacation'
- print '4) Division'
- cin = input('>>> ')
- if cin == 1:
- add()
- if cin == 2:
- sub()
- if cin == 3:
- mul()
- if cin == 4:
- div()
- def ipt():
- cls()
- print "1) Whats my IP"
- print "2) IP to Location"
- ipti = input('>>> ')
- if ipti == 1:
- cls()
- ip = urllib.urlopen('http://www.networksecuritytoolkit.org/nst/tools/ip.php').read()
- print('Your IP is '+ip)
- rq()
- if ipti == 2:
- cls()
- print("1) My Location")
- print("2) IP to Location")
- uin = input(">>> ")
- if uin == 1:
- cls()
- ip = urllib.urlopen("http://www.networksecuritytoolkit.org/nst/tools/ip.php").read()
- jipd = "http://ipinfo.io/"+ip+"/geo"
- jd = json.load(urllib.urlopen(jipd))
- print("You live in "+jd["city"]+", "+jd["region"]+" "+jd["country"])
- rq()
- if uin == 2:
- cls()
- print("Type IP to get Location of ")
- ip = raw_input(">>> ")
- jipd = "http://ipinfo.io/"+ip+"/geo"
- jd = json.load(urllib.urlopen(jipd))
- print("You live in "+jd["city"]+", "+jd["region"]+" "+jd["country"])
- rq()
- def bint():
- cls()
- print("1) Binary to text")
- print("2) Text to binary")
- uin = input(">>> ")
- if uin == 1:
- cls()
- print("Binary to convert")
- binaryt = input(">>> ")
- print(''.join(chr(int(binaryt[i:i+8], 2)) for i in xrange(0, len(bin_text), 8)))
- rq()
- if uin == 2:
- cls()
- print("Text to convert")
- raw = raw_input(">>> ")
- print(''.join('{:08b}'.format(ord(c)) for c in raw))
- rq()
- def rq():
- cls()
- print 'Do you want to restart?(y/n)'
- gbq = raw_input('>>>')
- a = gbq.lower
- cls()
- if a == 'y' or 'yes':
- start()
- if a == 'n' or 'no':
- import sys
- print 'Exiting'
- sys.exit(0)
- exit()
- def cls():
- if os == 'Windows' or 'Vista' or 'XP':
- sp.call('cls', shell=True)
- elif os == 'Linux' or 'Linux2' or 'Darwin':
- sp.call('clear', shell=True)
- else:
- print '\nUnable to clear screen!'
- main()
Advertisement
Add Comment
Please, Sign In to add comment