Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 318
Image: ubuntu2004
Kernel: Python 3 (system-wide)
print("Sum of values using for loop:") forSum = 0 for x in range(1, 6): print(x, end='') if x < 5: print("+", end='') forSum = forSum + x print("=", end='') print(forSum) print("Sum of values using while loop:") whileSum = 0 y = 1 while y < 6: print(y, end='') if y < 5: print("+", end='') whileSum = whileSum + y y = y + 1 print("=", end='') print(whileSum)
Sum of values using for loop: 1+2+3+4+5=15 Sum of values using while loop: 1+2+3+4+5=15