forked from Varadraj75/Python-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRevisionSession(13 sept).py
More file actions
72 lines (47 loc) · 1.45 KB
/
RevisionSession(13 sept).py
File metadata and controls
72 lines (47 loc) · 1.45 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
# Q1:- A student enters marks for 3 subjects as Strings. convert them to int and calculate the average.
subject_1 = float(input("Enter the maths score"))
subject_2 = float(input("Enter the science score"))
subject_3 = float(input("Enter the computer score"))
subject_1 = int(subject_1)
subject_2 = int(subject_2)
subject_3 = int(subject_3)
avg = subject_1+subject_2+subject_3 / 3
print(avg)
#Q2:- take a number age = 25. convert it into a string and print "My age is 25".
age = 25
print(f"My age is {age}")
#Q3:- A shopping site shows price as String "499.99". Add delivert charge(50 as int) and print the final bill.
price = ("499.99")
price = int(float(price))
delivery_charge = price+50
print(f"The final bill is {delivery_charge}")
#Q4:- Take a complex number z=5+2j.
# conver it into string.
# extract real and imaginary part as int
# print their sum
compl = 5+2j
real = int(compl.real)
img = int(compl.imag)
print(real+img)
#Fucntion
#defining the function
# in these age is the parameter
def isEligible(age):
# these age is reference of the value , which will be passed when the function is called
if(age>=18):
print("Eligible for voting!")
else:
print("Not Eligible for voting!")
age = int(input("Enter the age "))
#calling the function
# in these age is the argument
isEligible(age)
def Elig(ag):
if age<=18:
return False
return True
a= Elig(18)
if a:
print("Eligble")
else:
print("Not eligble")