Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
41 views
ubuntu2004
Kernel: Python 3 (system-wide)
t = 1000000 t = t // 60 s = t % 60 t = t // 60 m = t % 60 d = t // 24 h = t // 24 print ("1000000 seconds is", d , "days", h, ":", m, ":", s,)
1000000 seconds is 11 days 11 : 37 : 46
t = 8.12 r = 0.5 ** (1/t) d = 1.67 * 10 ** 12 / (10000 * r) a = 1.67 * 10 ** 12 * r * 7 print ( r, d, a)
0.9181789678562694 181881752.73705676 10733512134239.79
n = 235252525 x = 235252525 i = 0 while n > 1: n = n / 10 i = i + 1 print (x, "has", i, "digits")
235252525 has 9 digits
n = -235252525 x = -235252525 i = 0 if x >= 10: while n > 1: n = n / 10 i = i + 1 print (x, "has", i, "digits") elif x <= -10: while n < -1: n = n / 10 i = i + 1 print (x, "has", i, "digits") else: print (x, "has 1 digit")
-235252525 has 9 digits
n = -2 x = -2 i = 0 if x >= 10: while n > 1: n = n / 10 i = i + 1 print (x, "has", i, "digits") elif x <= -10: while n < -1: n = n / 10 i = i + 1 print (x, "has", i, "digits") else: print (x, "has 1 digit")
-2 has 1 digit
n = 5 print(n) while n > 1: if n % 2 == 0: n = n // 2 print (n) elif n % 2 == 1: n = 3 * n + 1 print (n)
5 16 8 4 2 1
n = 5 i = 1 while n > 1: if n % 2 == 0: n = n // 2 elif n % 2 == 1: n = 3 * n + 1 i = i + 1 print ("the Collatz number of 5 is", i)
the Collatz number of 5 is 6
def Collatz (n): while n > 0: if n % 2 == 0: n = n / 2 else: n = 3 * n + 1 i = i + 1 return i n = 0 c = 0 while c < 200: n = n + 1 c = Collatz (n) print ("the Collatz number of", n, "is", i)