-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpro1.py
More file actions
132 lines (103 loc) · 2.17 KB
/
Copy pathpro1.py
File metadata and controls
132 lines (103 loc) · 2.17 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
print("Hello World")
print("welcome to python programming")
print("this is my code")
print("I am Learning python", "AND", "I enjoy it")
"""this is a multiline comment and it can span multiple lines"""
name = "john"
print("my name is: " , name)
age = 23
rnum= 123
print("my roll number is: ", rnum)
print(" my age is: ", age)
fname= "esha"
age= 22
price= 102.3
old = None
ans = True
print(type(fname))
print(type(age))
print(type(price))
print(type(old))
print(type(ans))
# sum two numbers
a=10
b=20
c= a+b
print("sum of a and b is:", c)
print("sum of a and b is: ", a+b)
print("difference of:", a ," and",b, "is:",a-b)
#arithmatic operators
a=3
b=4
print("a+b:", a+b)
print("a-b:", a-b)
print("a*b:", a*b)
print("a/b:", a/b)
print("a%b:", a%b)
print("a**b:", a**b)
print("a//b:", a//b)
#assignment operators
c=10
print("c :", c)
c+= 5
print("c:", c)
c -= 5
print("c :", c)
c *= 5
print("c:", c)
c /= 5
print("c:", c)
c %= 5
print("c:", c)
c //=5
print("c:", c)
c **= 5
print("c:", c)
# relational and comparison operators
num1 = 10
num2 = 5
print("num1 is equal to num2:" ,num1==num2)
print("Num1 is lessthan or equal to NUM2:", num1<=num2)
print("Num1 is grater or equal to NUM2:", num1>=num2)
print("Num1 is lesser num2:", num1<num2)
print("Num1 is greather num2:", num1>num2)
print("Num1 is notequal or equal to NUM2:", num1!=num2)
# not operators
x = 50
y = 30
print(not(x > y)) # False
print(not(x < y)) # True
#type converion
p=2
h=4.6
sum=p+h
print("sum of p and h is:", sum)
p=2
h=4
sum=p+h
print("sum of p and h is:", sum)
assignment = "hello"
quiz = "world"
print("sum of:", assignment+quiz)
#type casting
a="12"
b=6.7
print("sum of a and b is:", float(a)+b)
a = "Ahmad"
b = "ahmad"
print(type(a))
sum = a + b
print(sum)
# input fuction
name = input("enter your name: ")
print("your name is: ", name)
age= (input("enter your age:"))
print(type(age))
print("your age is: ", age)
r1= float(input("enter any value in float:"))
print("the value you entered is: ", r1)
# Write aProgram to input 2 numbers &print their sum.
add1 = float(input("Enter first number: "))
add2 = float(input("Enter second number: "))
sum = add1 + add2
print("the sum of:",add1,"and",add2,"is:", sum)