String concepts in python Part 4

By // No comments:
There are some search and replace functions operations in strings as given below:-
1.) find():- The find() function returns the index value of the string where the substring is found between start index and end index.start index and end index is optional parameter.

  • If substring is present in given string then this function returns the index of the first occurrence of the substring.
  • If the substring is not exist inside the string then it returns -1 index
3

string concepts in python part 3

By // No comments:
String operations in python:
There are many Built-in string function available in python language.Here We will learn content test functions with examples as given below:-
1.) isalpha() :-It returns True ,if all characters in the string are alphabets otherwise False. The alphabets can be lower case and upper case both.This function doesn't take any parameters.If string contains a white space or any numeric value then this function returns False.
Syntax:-
String.isalpha()
3

Strings Concepts in Python Part 2

By // No comments:
String operators in Python:-There are some operators used to perform some basic operations on strings.
  • + (plus) operator) :-it is known as concatenation operator.it is used to concatenate two or more strings in python language.
e.g.
str1="Welcome to"
str2="MNT LAB"
str3="msdotnet"
str=str1+str2
print("Concatenate the two string: ",str)
print("Concatenate the two string: ",str1+' '+str3)
Output of Above Python program
Concatenate the two string:  Welcome toMNT LAB
Concatenate the two string:  Welcome to msdotnet
3

Strings concepts in python part 1

By // No comments:
What is Python strings?
  • Python string is a collection of Unicode characters.
  • String is a popular data type of python language.
  • Python allow us to create the string by using single quotes,double quotes or triple quotes.
  • Strings can be created by enclosing the the character or the sequence of characters in the quotes(single,double or triple ) in python language.
We can create a string in python in following way as given below:-
3

Operators in Python with examples

By // No comments:
Operators are special symbols in python which are responsible for a particular operation between two or more operands.Operators are more helpful for doing operations between two operands.We will learn everything about different type of operators in python with examples.
e.g.
a=5;b=6;
c=a+b
print("value of a+b= ",c)
Output of above program:-
value of a+b= 11
Descriptions:- In above program
operators --> =,+
operands --> a,b,c
There are many variety of operators present in python as follows:-
  1. Arithmetic operators
  2. Comparison operators
  3. Assignment operators
  4. Logical operators
  5. Bitwise operators
  6. Membership operators
  7. Identity operators
3

Print() function in python Language with examples

By // No comments:
The print() function is used for sending the output to the screen.It is used to display the output of any variables like string,list,tuple,set,dictionary,etc.Print() function is a built-in function in python language.
Syntax:-
print(*objects,sep=' ',end='\n',file=sys.stdout,flush=False)

Descriptions:-

  1.) objects:-The object can be Integer,Float,string,list,tuple,set,etc.
e.g.

a=234
b='ram'
list=[1,2,3,4,5,6]
tuple=(1,2,3,4,5,6)
dictionary={'a':'apple','b':'bag','c':'cat','d':'dog'}
set={'a','e','i','o','u'}
print("value of a=",a)
print("value of b=",b)
print("value of list=",list)
print("value of tuple=",tuple)
print("value of dictionary=",dictionary)
print("value of set=",set)
print("value of 12*45=",12*45)
output of the above python program:-
value of a= 234
value of b= ram
value of list= [1, 2, 3, 4, 5, 6]
value of tuple= (1, 2, 3, 4, 5, 6)
value of dictionary= {'a': 'apple', 'b': 'bag', 'c': 'cat', 'd': 'dog'}
value of set= {'o', 'e', 'i', 'a', 'u'}
value of 12*45= 540

  2.) sep=' ' :-This parameter is used to give space between multiple objects.You an use this parameter other than space also.It will be shown in below programs.
e.g.
a=5
b=6
c=24
d=60
e='ram'
f='sita'
print("value of a,b,c,d=",a,b,c,d)
print("value of a,b,c,d=",a,b,c,d,sep='  ')
print("value of a,b,c,d=",a,b,c,d,sep=',')
print("value of a,b,c,d=",a,b,c,d,sep='\n')
print("value of e,f =",e+' '+f)
output of the above python program:-
value of a,b,c,d= 5 6 24 60
value of a,b,c,d=  5  6  24  60
value of a,b,c,d=,5,6,24,60
value of a,b,c,d=
5
6
24
60
value of e,f = ram sita
  3.) end=' \n' :-It means,when we call print () function each time.it will end at a new line.In python by default ,print() function always ends at a new line.You can change it. i will see in the programs.
3
Powered by Blogger.