Python subject
Python subject
1. Concatenation (+):
Str2= “Welcome”
Str3= str1+str2
Print(str3)
Repetition (*):
Boolean methods:
Sting methods that will evaluate to a Boolean value. The methods are useful
when we creating forms for the user to fill. Eg., for Postal code it will accept only
numeric string.
Methods:
Str.isalnum( )-> Check whether the string contain alpha numeric characters
Str.isalpha( ) -> String consists only alphabetic character
Str.islower( ) -> Check whether the string characters are in lower case
Str.isspace( ) -> Checks all the characters are white space character
String Modules:
print(“lower()=”, text.lower()
find( )=0
count( )=2
List as array
Instead of array we can use list and list functions & methods.
List is also a dynamic mutable type and this means you can add and delete
elements from the list at any time.
mylist=[1,2,3,4,5,6,7]
mylist[2]=100
print(mylist)-> [1,2,100,4,5,6,7]
print(mylist[2:5]) ->[100,4,5]
print([0:]) ->[1,2,100,4,5,6,7]
print([:]) ->[1,2,100,4,5,6,7]
print([:5]) ->[1,2,100,4,5]
Concatenation: (+ operator)
Eg: a=[1,2]
b=[4,5]
c=a+b
Repetition:
Eg: a=[1,2]
c=a*2
print(c ) ->[1,2,1,2]