My Python Code

First Code Print

print (kisi cheeze ko print karne ke liye “print”use kya jata hai)

#Print

print(“Hello World!”)

a = 46

b = 50

z = a + b

print(z)

2nd code Comment and Indentation

Comment (Agr ap kisi cheeze ko comment karna chahtay hain to # ko use kare)

#Comment and Indentation

print(“Hello World! 1”)

print(“Hello World! 2”)

print(“Hello World! 3”)

print(“Hello World! 4”)

Multiple files ko comments karne ke tareeqa

“””

print(“Hello World! 5”)

print(“Hello World! 6”)

print(“Hello World! 7”)

print(“Hello World! 8”)

“””

Indentation (Mean lines me space nhi honi chahye)

print(“Hello World! 9”)

print(“Hello World! 10”)

3rd Code variable

Variable define karne ka tareeqa
A-Z, a-z, 0-9, _
e.g. “name_1
age1
_name1″
In python, the name is not the same Name
both are different
x is not equal to X

Multiple Words Technique
Camel Case:
myName = “Waleed”
myAge = “21”
Pascal Case:
MyName = “Waleed”
MyAge = “21”
Snake Case:
my_name = “Waleed”
my_age = “21”

Veriable Types
x = 10
y = “Waleed”
agr veriable type ka pata lagana ho to “print(type(x))
If x = 10 then ‘x = int’ ho ga
If x = 10.5 then ‘x = float’ ho ga
If x = “name” then ‘x = string’ ho ga

Casting
int ko float me or float ko int me or str ko int me change karne ko casting kehte hain
int to float
a = 20
print(float(a))

float to int
b = 50.05
print(int(b))

int to str
c = 34
print(str(c))

kisi bhi veriable ko delete karne ke liye “del” ka use karte hain

Code

#Veriable

”’

x = y = z = 10

print(y)

x, y, z = 36, 56, 66

print(z)

”’

x = 25

print(type(x))

y = 25.7

print( type(y))

z = “Waleed”

print( type(z))

w = ‘Waleed’

print(type(w))

#int to float

a = 20

print(float(a))

#float to int

b = 50.05

print(int(b))

#int to str

c = 34

print(type(str(c)))

4th Code Output Input

⦁ Output/Input
Multiple verables ko print karne ka tareeqa
x = 10
y = 20
z = 30
print(x, y, z)
or
print(“Hello World”, “Hello World”, “Hello World”)

Way to Print
name = “Waleed”
country = “Pakistan”
age = 21
print(“My name is”, name, “and I live in”, country)
print(“My name is “+name+ “and my age is “+ country)
print(f”My name is {name} and my age is {age}”)
print(“My name is “+name+ ” and my age is “+ str(age))

veriable ko aik hi line me lane ke liye “print(x, end= “=”) ka use kar sakte hain

Input
User se data lene ke liye input ko use kya jata hai
e.g.
name = input(“Enter Your Name”)
print(f”Your name is {name})

input always give result in str form
Agr ap mathmatic question karna chahtay hain to str ko int me change karna zarori

Code

x = 10

y = 20

z = 30

print(x, y, z)

print(“Hello World”, “Hello World1”, “Hello World2”)

print(“Waleed” , end= ” = “)

print(“dawood” ,  end= ” = “)

print(“Awais”)

name = “Waleed”

country = “Pakistan”

age = 21

print(“My name is”, name , “and I live in”, country)

print(“My name is “+name+ “and I live in “+country)

print(“My name is “+name+ ” and my age is “+str(age))

print(f”My name is {name} and my age is {age}”)

#input start

name = input(“Please Enter Youor Name”)

print(f”Your name is {name}”)

print(type(name))

#Sum Input

a = float (input(“Enter Value of x”))

b = float (input(“Enter Value of y”))

c = a + b

print(f”Sum of {a} and {b} is equal to {c}”)

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button