Learning python - 2nd day (Noon)
I have completed this tutorial: Python Tutorial 5
I learnt now is about variables and some String modifier functions.
The first thing I learnt is I can store a value or a string in a variable name just like java and C++.
The difference is unlike other languages, there is no need of writing the variable type before specifying. Storing data in a variable is as simple as:
myNumber=8
Well I also learnt that I can modify a String variable in several ways.
For example:
text='Shadow'
Way 1:
Input: text[0]
Output: S
Input: text[-1]
Output: w
Well so 0,1,2,3,4,5 is the character number... Let me define it much easy way:
S h a d o w
0 1 2 3 4 5
-6 -5 -4 -3 -2 -1
Just like this.
Way 2: I can extract certain part from String
Input: text[0:3]
Output: Sha
Meaning like 012 characters from String
If I put null value the character indexes will be count till end.
Like:
Input: text[2:]
Output: adow
Or like 2345
Another special function I learnt is character counting from a String
Input: len(text)
Output: 6
Comments
Post a Comment