top of page

Sample Code of Python

  • Writer: Jino Shaji
    Jino Shaji
  • Jan 7, 2015
  • 1 min read

Updated: Jun 9, 2020


Look at a sample of code Of Python…


 x = 34 – 23            # A comment.

 y = “Hello”            # Another one.

 z = 3.45   

 if z == 3.45 or y == “Hello”:

     x = x + 1

     y = y + “ World”   # String concat.

 print x

 print y

Enough to Understand the Code

•Assignment uses = and comparison uses ==.

•For numbers +-*/% are as expected.

–Special use of + for string concatenation.

–Special use of % for string formatting.

•Logical operators are words (and, or, not

not symbols (&&, ||, !).

•The basic printing command is “print.”

•First assignment to a variable will create it.

–Variable types don’t need to be declared.

–Python figures out the variable types on its own

.  

Recent Posts

See All
Program to Create an investment report.

“””Program: investment.py Author: JINO SHAJI Compute an investment report. 1. The inputs are        starting investment amount       ...

 
 
 

Comments


bottom of page