-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignmenty.py
More file actions
105 lines (78 loc) · 1.79 KB
/
assignmenty.py
File metadata and controls
105 lines (78 loc) · 1.79 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
#task1
a = 67 #integer
b = "string value" #string
c = 8.99 #float/decimalval
d = True #booloean
print(type(a)) #int
print(type(b)) #str
print(type(c)) #float
print(type(d)) #bool
print(a) # 67
print(b) # string value
print(c) # 8.99
print(d) # True
#task2
def check_even_odd(num):
if num % 2 ==0: # it'll check num is odd o even
print("even") # gonna execute if num is even
else:
print("odd") # if number is odd
check_even_odd(55)
#task3/4
# list numbers
list = [1,2,3,0,4,5,-8,0,6,-11,77]
# loop through each value in list to check +ve 0 -ve
for i in list:
if i > 0:
print("+ve")
elif i == 0:
print("val==0")
else:
print("-ve")
#task5
#main func to find out factorial of given func
def factorial(x):
a = 1
while x > 0:
a *= x
x = x - 1
return a
zx = int(input("enter numbr : "))
r = factorial(zx)
print(f"factorial of {zx} is {r}")
# for doing joining( concatenation) in tupple
tuple1=('red','yellow','green')
tuple2=('1','2','3')
tuple3=tuple1+tuple2
print(tuple3)
car = {
"brand": "Ford"
,"model": "Mustang",
"year": 2020}
x = car.values()
print(x)
#before the change
car["year"] = 2024
print(x)
car["year"] = 2025
print(x)
print("Yes, 'model' is one of the keys in the dictionary")
dictionary={
"brand": "Ford",
"model": "Mustang",
"year": 2023}
dictionary["model"]
print(dictionary)
dictionary = {
"brand": "Ford",
"model": "Mustang",
"year": 2026}
mydict=dictionary.copy()
print(mydict)
#split
spl="HELLO,WORLD"
xdd=spl.split(",")
print(xdd)
#replace
cff="HI,BROTHER"
print(cff.replace("E","J"))