Wednesday, August 20, 2014

Computer Science Circles (0:Hello!~2:Function)

I record about computer programming. I learn from Computer Science Circles.
http://cscircles.cemc.uwaterloo.ca/0-introduction/

I had done excise are:
0:Hello!
1:Variable
1E: Error
2:Function

[print] is Python code to send messages to output.
   Example: print("Hello")
   ( ) This is print command to use what you want to print
   " " If there aren't " " mark, Hello is meant to be command

Example:Variable
x=5             (x=5)
x=x+x         (x=5+5=10)
x=x-5          (x=10-5=5)
So, x=5 after execute these command

Error
run-time error happens when Python understands what you are saying, but runs into trouble when following your instructions. A syntax error happens when Python cannot understand what are you saying.
Example: Run-time error
print(1/0)
Example: Syntax error
print(Hello) 

Function
Example:
print(max(1,2,3))
This command will print 3
+plus - minus *times /divide

No comments:

Post a Comment