Tuesday 3 September 2019

python notes

Basics

variables and assignment

Variable can be combination of only letters and numbers and underscore "_". Can't start with a number. Variable names are case sensitive. Also, variable cannot have reserved words in python.

Types:-
  1. Integer: stores integer values, 1, -12 etc. "x=1".
  2. Float: stores floating values like 1.0, 1.2e-12 etc. "x=-12.56","x=float(1)".
  3. Complex: stores complex numbers. "x=1e12 + 12.65j","x=complex(1.5)".
  4. string: stores text in form of string of letters. "x="this is a string of words"".
"x=1" is same as "x = 1". Spaces in the beginning of a line has a meaning.

Input and output statements

  • print(x),print("the value of x is",x," and the value of y is",y)
  • x=input("the value of x is:")