-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bascis of python .py
60 lines (48 loc) · 1.09 KB
/
Bascis of python .py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
print("hello") #just printing
x=5 #variable #no command for declaring
print(type(x)) #print data type of x
a=2
b=5
print(a*b)
y=input("enter kro kuch bhi") #y will store input value
if(y==""):
print("y is a string")
else:
print("y is integer or maybe string or maybe mujhy nh pta")
z=6
if(z > 4 and z < 8):
print("correct")
else:
print("not correct")
#functions
def say_hi(name):
print("hello my name is "+name)
say_hi("maida")
t=input("your name")
say_hi(t)
#classes and objects
class Person:
def __init__(self,name,age):
self.name=name
self.age=age
def actual_func(a):
print(a.name+" "+a.age)
u=input("name")
v=input("age")
p1=Person(u,v)
p1.actual_func()
#inheritance
class Car(Person):
pass #no own func if class car
class vehicle(Person):
def __init__(self,vname,vno):
self.vn=vname
self.vnum=vno
def Details(b):
print(b.vn+""+b.vnum)
C1=Car("david","45")
C1.actual_func()
s=input("name of vehicle")
t=input("Id of vehicle")
V1=vehicle(s,t)
V1.Details()