Sunday 9 August 2020

Python Programming Basic ( Part =2. )

                                           (  Part=2.  )

                                                   Lesson =13.


 ---------Solved the space problem.-----------

Example 1.
name="Asalm   abs"
dots="................."
print(name.strip()+ dots)
print(name.replace(" ","") + dots)


 ---------------------Replace () method--------------------------

Example 1.
name='She is a good girl'
print(name.replace("is","was"))


# String are immutable.
Example 2.
name="asalm"
print(name.replace("a","A"))


 ------------------------- find () method-------------------------

Example 1.
String="She is a good girl name he is a good boy"
print(String.find("is",6))
  
  

-------------------Center () method ---------------------

Example 1.
name="MOHMMADASALM"
print(name.center(30,"*"))


---------------More then assigement operater---------------------

Example 1.
name=10
name+=1    # 1.+=, 2.-=, 3.*=, 4.%=, 5./+, 6.//=, 7.**=
print(name)


                                                           Lesson 14.


       ------------------------ All Statement--------------------


-------------if statement----------

 Example  1.
a=10
b=20
if (a<b):
  print("True")

Example  2.    (From User)
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
if (a<b):
  print("True")

 Example 3.
if 10>2:
 print("True")
 
 Example 5.
 age=15
 age=int(age)
 if age>=14:
   print("You are about 14")
  
   Example 6.
 # age=int(input("Enter your age:"))
 # if age>=14:
 #  print("You are about 14 Year")
   

--------if else statement----------

Examlpe 1.  (From User)
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
if (a>b):
  print("True")
else:
 print("False") 
  
 Example 2.
age=14
if age>=15:
 print("You are above 15")
else:
 print("You are above 15")
 

----------------Nested if else-----------------

Example 1.  (From User)
number =20
user=int(input("Enther the number :"))
if user==number:
 print("You win !!!")
else:
 if number>user:
  print("Too low")
 else:
  print("Too high") 
 
 

                                                        Lesson 15.

       ---------and , or operator---------

Example 1.

a=10

b=10

c=30

d=10

if ((a==b) and (c==d)):
 print("Condition True")
else:
 print("Condition is Fals") 
 
 Example 2.
a=10
b=10
c=30
d=30
if ((a==b) or (c==d)):
 print("Condition True")
else:
 print("Condition is Fals") 
 

  

No comments:

Post a Comment

Full stack web development

                                                Smart Home Website