-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday_1.py
More file actions
83 lines (65 loc) · 1.71 KB
/
Copy pathday_1.py
File metadata and controls
83 lines (65 loc) · 1.71 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
#simple printing code
age = 20
year = 2026
temperature = -5
print(age)
print(year)
print(temperature)
#This is a program for parameter of square
side=int(input("Enter the size of a side:"))
parameter=4*side
print("The parameter of square =",parameter)
#This is a program for circumference of circle
PI=3.14
radius=float(input("Enter the radius of circle:"))
circumference=2*PI*radius
print("the circumference of circle=",circumference)
#this is a program for simple interest
p=float(input("Enter the value of p:"))
r=float(input("Enter the value of R:"))
t=float(input("Enter the value of t :"))
simple_interest= p*r*t/100
print("THE SIMPLE INTEREST=",simple_interest)
#this is a program for basic maths operations
a = 10
b = 3
print(a + b) # addition
print(a - b) # subtraction
print(a * b) # multiplication
print(a / b) # division (always returns float)
print(a // b) # floor division
print(a % b) # modulus (remainder)
print(a ** b) # exponent (power)
# To Find the type of different values in Python
# Integer
a = 10
print(a, type(a)) # int
# Float (this replaces double in Python)
b = 10.5
print(b, type(b)) # float
# String (used instead of char)
c = "A"
print(c, type(c)) # str
# String with multiple characters
d = "Hello"
print(d, type(d)) # str
# Boolean
e = True
print(e, type(e)) # bool
# None type (represents no value)
f = None
print(f, type(f))
#Now creating strings
name = "Amrita"
greeting = 'Hello'
sentence = "Python is fun!"
print(name)
print(greeting)
print(sentence)
# To find String length
print(len(name))
print(len(sentence))
# Converting strings to upper and lower case
text = "Hello Python"
print(text.upper()) # HELLO PYTHON
print(text.lower()) # hello python