Advertisement
Dar954826

Fraction Generating[ENG].py

Jan 12th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.09 KB | None | 0 0
  1. def generat():
  2.  try:
  3.   import os,sys,string
  4.   m=string.punctuation
  5.   m=m.replace("(","")
  6.   m=m.replace(")","")
  7.   m=m.replace(".","")
  8.   nuk=True
  9.   c=d=newd=""
  10.   num=2
  11.   e=newe="   "
  12.   print("Enter the term in parentheses")
  13.   print("To separate decimals using the dot (.) Not the comma (,)")
  14.   a=input("Insert number: ")
  15.   for kjkj in string.ascii_letters:
  16.    if a.count(kjkj)!=0:
  17.     6/0
  18.   for kjkjk in m:
  19.    if a.count(kjkj)!=0:
  20.     6/0
  21.   dot=a.find(".")        
  22.   no=a.replace(".","")    
  23.   no=no.replace("(","")
  24.   no=no.replace(")","")
  25.   pernum=a.find("(")      
  26.   pernum1=a.find(")")      
  27.   if pernum!=-1 and pernum1!=-1:
  28.    per=a[pernum+1:pernum1]  
  29.    noper=no[0:pernum-1]      
  30.    anti=a[dot+1:pernum]      
  31.    print(a+" "+no+" "+per+" "+noper+" "+anti)
  32.    b=int(no)-int(noper)
  33.    for l in range(len(per)):
  34.     c=c+"9"
  35.    for ll in range(len(anti)):
  36.     c=c+"0"
  37.  
  38.  
  39.   else:
  40.    cc="1"
  41.    zz=a[dot:len(a)-1]
  42.    for lll in range(len(zz)):
  43.     cc=cc+"0"
  44.    c=cc
  45.    b=no
  46.   if len(str(c))<len(str(b)):
  47.    for kk in range(len(str(b))):
  48.     d=d+"-"
  49.   else:
  50.    for kk in range(len(str(c))):
  51.     d=d+"-"
  52.   for hkj in range(len(a)):
  53.    e=e+" "
  54.   print(e+str(b))
  55.   print(a+" = "+d)
  56.   print(e+str(c))
  57.   print("Ongoing simplification: [Ctrl + c in the case of block in case of very large numbers]")
  58.   while True:
  59.    if int(c)%num==0 and int(b)%num==0:
  60.     break
  61.    else:
  62.     num=num+1
  63.     if num>int(c):
  64.      nuk=False
  65.      break
  66.   if nuk:
  67.    newb=str(int(int(b)/num))
  68.    newc=str(int(int(c)/num))
  69.   else:
  70.    newb=b
  71.    newc=c
  72.   if len(str(newc))<len(str(newb)):
  73.    for kkk in range(len(str(newb))):
  74.     newd=newd+"-"
  75.   else:
  76.    for kkk in range(len(str(newc))):
  77.     newd=newd+"-"
  78.   for hkj in range(len(str(b))-len(str(c))):
  79.    newe=newe+" "
  80.   print(str(b)+"   "+newb)
  81.   print(str(d)+" = "+newd)
  82.   print(str(c)+newe+newc)
  83.   input("ENTER to cancel
  84.  print("\n"*1000)
  85. except KeyboardInterrupt:
  86.  input()
  87.  input("ENTER to cancel")
  88.  print("\n"*1000)
  89. except ZeroDivisionError:
  90.  input("You may not post letters, ENTER to cancel")
  91. while True:
  92. generat()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement