from math import *#this code includes a check-up b=1 while(b!=0): b=int(raw_input("number")) x=3 n=2 y=log(2)+log(3) while (n3): a=a-2 else: y=y+log(x) a=1 n=n+1 print x y=y-log(x) print y print (y/x)#in the beginning of RUN press ENTER(if there is an empty space) This is ps1 p2.Can you find more efficient way to solve this problem?I think mine is too long and runs slow
you should use comments and descriptive variable names seems to get the right answer but i can't figure out what it is doing
bwCA-whats that for?
it is set on an infinite loop so you can check sum of log to number n using different n's.You will notice as n increases ratio gets closer to 1
I will answer what I can for bwCA. The code pasting is for the easiness of reading the code with syntax highlighting, and it doesn't mess up with the indentation, as pasting like you did does. The commentaries and descriptive names are a must. Python is a loosely-typed language, and when the programs start to get bigger, it is almost impossible to understand (even if you are the one who did the code). Even this piece of code, when you see it again in a couple of months, likely you won't remember what it does and how it works. Avoid using a, b, stuff like that for variable names. Rather, use sumofLogs, numtoTest, and the likes :-) Kudos for the solution, mate.
Join our real-time social learning platform and learn together with your friends!