Uploaded by nadhiya rafeek

PYTHON

advertisement
PYTHON
Python 2 and 3
2- legacy version
3-latest version
Print-console
Data and variables
1. When we create a variable name with 2 words always use _ to separate
it
2. Storing strings only need quotation marks
3. Storing numbers doesn’t need quotation marks
4. Boolean values
Strings
1.\n- new line
Functions
Name=”Ryan”
Print(Name.isupper())
Print(len(Name))
Print(Name.index(“R”))
Print(Name.replace(“Ryan”,”Anish”)
Print(Name[3])
Numbers
Normal arithematic
1)To print s number with a string always use the function str()
List
To extend 2 list
List1.extend(list2)
2)To add individual element to the end of a list
Use append
List1.append(“Nadhiya”)
3)To insert element inbetween of the list
Use insert
List1.insert(“Nadhiya”)
Download