Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def generat():
- try:
- import os,sys,string
- m=string.punctuation
- m=m.replace("(","")
- m=m.replace(")","")
- m=m.replace(".","")
- nuk=True
- c=d=newd=""
- num=2
- e=newe=" "
- print("Inserire il periodo tra parentesi tonde")
- print("Per separare i decimali usare il punto(.)non la virgola(,)")
- a=input("Inserire numero: ")
- for kjkj in string.ascii_letters:
- if a.count(kjkj)!=0:
- 6/0
- for kjkjk in m:
- if a.count(kjkj)!=0:
- 6/0
- dot=a.find(".")
- no=a.replace(".","")
- no=no.replace("(","")
- no=no.replace(")","")
- pernum=a.find("(")
- pernum1=a.find(")")
- if pernum!=-1 and pernum1!=-1:
- per=a[pernum+1:pernum1]
- noper=no[0:pernum-1]
- anti=a[dot+1:pernum]
- print(a+" "+no+" "+per+" "+noper+" "+anti)
- b=int(no)-int(noper)
- for l in range(len(per)):
- c=c+"9"
- for ll in range(len(anti)):
- c=c+"0"
- else:
- cc="1"
- zz=a[dot:len(a)-1]
- for lll in range(len(zz)):
- cc=cc+"0"
- c=cc
- b=no
- if len(str(c))<len(str(b)):
- for kk in range(len(str(b))):
- d=d+"-"
- else:
- for kk in range(len(str(c))):
- d=d+"-"
- for hkj in range(len(a)):
- e=e+" "
- print(e+str(b))
- print(a+" = "+d)
- print(e+str(c))
- print("Semplificazione in corso:[Ctrl+c in caso di blocco in caso di numeri molto grandi]")
- while True:
- if int(c)%num==0 and int(b)%num==0:
- break
- else:
- num=num+1
- if num>int(c):
- nuk=False
- break
- if nuk:
- newb=str(int(int(b)/num))
- newc=str(int(int(c)/num))
- else:
- newb=b
- newc=c
- if len(str(newc))<len(str(newb)):
- for kkk in range(len(str(newb))):
- newd=newd+"-"
- else:
- for kkk in range(len(str(newc))):
- newd=newd+"-"
- for hkj in range(len(str(b))-len(str(c))):
- newe=newe+" "
- print(str(b)+" "+newb)
- print(str(d)+" = "+newd)
- print(str(c)+newe+newc)
- input("INVIO per cancellare")
- print("\n"*1000)
- except KeyboardInterrupt:
- input()
- input("INVIO per cancellare")
- print("\n"*1000)
- except ZeroDivisionError:
- input("Non puoi inserire lettere, INVIO per cancellare")
- while True:
- generat()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement