Advertisement
Dar954826

Semplificazioni[ITA].py

Jan 1st, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. def simple():
  2.  e=f=g=u=m=ppp=ppz=""
  3.  s=" "
  4.  pp=pz=0
  5.  a=int(input("Inserisci Primo Numero: "))
  6.  b=int(input("Inserisci Secondo Numero: "))
  7.  if a<0:
  8.   s="-"
  9.   a=a*-1
  10.  if b<0:
  11.   s="-"
  12.   b=b*-1
  13.  if a<b:
  14.   x=a
  15.   e=len(str(b))
  16.  else:
  17.   x=b
  18.   e=len(str(a))
  19.  while True:
  20.   if a%x==0 and b%x==0:
  21.    break
  22.   x=x-1
  23.  c=a/x
  24.  d=b/x
  25.  if c<d:
  26.   u=c
  27.   k=len(str(d))
  28.  else:
  29.   u=d
  30.   k=len(str(c))
  31.  for o in range(e):
  32.   g=g+"-"
  33.  for ok in range(k):
  34.   m=m+"-"
  35.  if a>b:
  36.   pp=len(str(a))-len(str(b))
  37.  else:
  38.   pz=len(str(b))-len(str(a))
  39.  for cy in range(pp):
  40.   ppp=ppp+" "
  41.  for cyl in range(pz):
  42.   ppz=ppz+" "
  43.  j="  "+str(a)+ppz+"      "+str(c)
  44.  jj=s+" "+g+"  = "+s+" "+m
  45.  jjj="  "+str(b)+ppp+"      "+str(d)
  46.  print(j)
  47.  print(jj)
  48.  print(jjj)
  49.  
  50. while True:
  51.  simple()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement