Smart Home Website
Mr. Asalm Web Designer
Friday, 17 June 2022
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")
Tuesday, 4 August 2020
Saturday, 1 August 2020
Python Programming Basic ( Part =1. )
( Part =1. )
( AS A PROGRAMMAR BOY)
( STEDEY BY ENGEENERING COLLEGE )
Lesson =1.
1.
print('1------\\"=Duble Quote--------')
print("Helo Welcome To \" MMIT \" My College")
print(" ")
2.
print("2------\\'=Single Quote--------")
print("I'm a good boy")
print(" ")
3.
print("3-----------\\\\=backslalsh-----------")
print("MOHMMAD ASALM\\\\")
print(" ")
4.
print("4---------\\n=New Line---------------")
print("List1 \n List2")
print(" ")
5.
print("5----------\\t=tab---------------")
print("List1 \t List2")
print(" ")
6.
print("6-------------\\\\=Backspace---------- ")
print("Backspace-\\\\\\\\")
7.
print("7-------------backspace-----------")
print("\bHelo welcome to my college")
Lesson =2.
print("1==========\\t=Normal Text=========")
print("\tMy college name is \\t MMIT ")
print(" ")
print("2===========More them Backslash\\\" \\\'==========")
print("\t\\\" and \\\'")
print(" ")
print("3==========This is a /\\/\\/\\/\\ mountan=========")
print("\t/\\/\\/\\/\\")
print("4==========Many type of backspash============")
print("\t\"")
print(" ")
print("5==========Row String=========")
print("\t",r"\t Line1 \n Line2")
Lesson = 3.
****** Calculator ******
print("1---------To Number Additin-----------")
print("\t",3+2)
print(" ")
print("2------------To Number Subtraction---------")
print("\t",3-2)
print(" ")
print("3----------To Number Multiplication-------")
print("\t",3*2)
print(" ")
print("4--------To Number Float Division--------")
print("\t",10/2)
print(" ")
print("5-------To Number Integer Division--------")
print("\t",13//2)
print(" ")
print("6--------To number Modulo it gives reminder--------")
print("\t",13%2)
print(" ")
print("7--------Exponent---------")
print("\t",2**5)
Lesson = 4.
********* Precedence Rule *********
# Example 1.
print("\t\t\t",(4+3%(3*2))*(20-10))
print(" ")
Lesson =5.
.--------------String Concatenation----------
Example 1.
frist_name="MOHMMAD "
Second_name="ASALM"
aup_name="1290"
a=frist_name+Second_name
b=Second_name+aup_name
print("\t\tTwo String Add:",a)
print("\t\t\tASALM and 4 Add:",b)
.----------String User Input Function:------------
Example 2
name=(input("Enter Your Age:"))
a=int((name))
print("Helo",a)
print(type(a))
Lesson =6.
-----------int () Function--------------
Example 1.
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
c=a+b
print("\t\t\tTwo Number Addition:"+str(c))
print(type(c))
Example 2.
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
c=a-b
print(''Two number subtraction:",c)
Example 3.
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
c=a*b
print(''Two number multiplaction:",c)
Example 4.
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
c=a/b
print(''Two number division:",c)
Lesson =7
--------------------More about variables-------------------
Example 1.
name , age="MOHMMAD ASALM","10"
print("Helo"+name+"Your Age:"+age)
print(type(age))
Lesson =8.
-----------one line input-----------
Example 1.
name , age=input("Enter the name and age :").split()
print(name)
print(age)
---------String formating---------
Example 1.
name="Asalm"
age="24"
print("Hello\t"+name+"\tYour age is :"+age)
Example 2.
name="Asalm"
age="24"
print("helo\t{} \tYour age is :{}".format(name,age))
print(f"Helo\t{name}\t your age is :{age}")
Lesson= 9.
Example 1.
a=int(input("Enter the First number:"))
b=int(input("Enter the Second number:"))
c=int(input("Enter the third number:"))
print(f"Avrage of the three number :{a+b+c/2}")
Lesson=10.
......................... Split() Methon ................
a,b,c=input("Enter the three number comma separated:").split()
print(f"Avrage of the three number :{(int(a)+int(b)+int(c))}")
or
a,b,c=input("Enter the three number comma separated:").split(",")
print(f"Avrage of the three number :{(int(a)+int(b)+int(c))}")
print("Average of the three number:{}{}{}".format(a,b,c))
Lesson=11.
....................................... All String Method ..............................................
print("--------------String Indexing----------")
1.
language="Python"
print(language[0])
print(language[1])
print(language[2])
print(language[3])
print(language[4])
print(language[5])
2.
language="Python"
print(language[0])
print(language[-1])
print(language[-2])
print(language[-3])
print(language[-4])
print(language[-5])
print(language[-6])
------------------------String Slicing ()---------------------------
1.
language="Python"
print(language[1:5])
......................................... Reverse () Methon ..................
Example 1.
name=input("Entre the name:")
print(f"reverse of your name is\t{name[-1::-1]}")
Example 2.
name="MOHMMAD"
reverse=name[-1::-1]
print("Reverse of the string :"+reverse)
***************** String method ****************
1. len () function
2. lower () method
3. upper () method
4. title () method
5. count () method
++++++++++ 1. len () function ++++++++++
a="MOHMMAD ASALM"
B=len(a)
print("String of the length:",B)
print(type(a))
print(type(B))
+++++++++ 2. lower () Method. +++++++++++
name="MOHMMAD ASALM"
B=name.lower()
print("String of the lower:",B)
print(type(name))
print(type(B))
++++++++++++++ 3.Upper () method. ++++++++++++++
name="MOHMMAD ASALM"
B=name.upper()
print("String of the upper:",B)
print(type(name))
print(type(B))
+++++++++++ ++4. title () method.+++++++++++++++
name="MOHMMAD ASALM"
B=name.title()
print("String of the title:",B)
print(type(name))
print(type(B))
+++++++++++++++ 5. count () method.++++++++++++
name="MOHMMAD ASALM"
print("String of the count:",B)
print(type(name))
print(type(B))
Lesson =12.
----------More them variable in single line.------
Example 1.
name="Asalm."
age=29
print("helo\t"+name+"\tYour age is:"+str(age))
print("helo\t{}\tYour age is:{}".format(name,age))
print(f"helo\t{name}\tYour age is:{age+4}")
--------More the inpuut single line----------
Example 1.
name,age=input("enter the your name and your age:").split()
print(name)
print(age)
---------......... String Reverse ........ ------------
Example 1.
name=input("Enter your string name:")
reverse=name[-1::-1]
print(reverse)
print(f"Reverse is your name :{reverse}")
Subscribe to:
Posts (Atom)
Full stack web development
Smart Home Website
-
( Part=2. ) Lesson =13. ---------Solved th...