-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathself.py
More file actions
172 lines (108 loc) · 3.14 KB
/
self.py
File metadata and controls
172 lines (108 loc) · 3.14 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# # name=input("My name is :")
# # Age=int(input("my age is :"))
# # marks=float(input("I get max:"))
# # print("welcome =", name)
# # print("Your age =", Age)
# # print("congratulations you got =", marks)
# # first=int(input("Enter first = "))
# # second=int(input("Enter second = "))
# # print("sum = ", first + second)
# #Print the sum of side of square
# side = float(input("enter area of square:", ))
# print('area = ',side*side)
# #strings
# str1 = "n tbhis is the string .\nmy name uis"
# print(len(str1))
# #INDEXING
# str ="Apna college"
# ch= str[0]
# print(ch)
# #Slicing
# str ="Ashutosh"
# print(str[-8:-3])#Negative slicing
# print(str[2:7])
# #Sring functions
# str ="my name is ashutosh" #Returns true str if str ends with subsitute
# print(str.endswith("osh"))
# print(str.capitalize())#Capitalize the starting word of sentence
# print(str.replace("name","namm"))#used to change the word from sentence
# #Conditional statement
# light = input("what is the color of light :")
# print(light)
# if(light =="red"):
# print("stop")
# elif(light =="yellow"):
# print("start")
# elif( light =="green"):
# print("gooo!!!")
# else:
# print("light is broken ")
# #Nesting
# whether= input("What is today whether: ")
# friends= True
# if whether =="sunny":
# print("go for a walk and go to gym")
# else:
# print("play with friends ")
# if whether == "rainy":
# print("read books")
# else:
# print("eat maggies")
# #WAP to find the greatest o]f 4 numbers input by user
# a=int(input("Enter your first digit: "))
# b=int(input("Enter your second digit: "))
# c=int(input("Enter your third digit: "))
# d=int(input("Enter your forth digit: "))
# if(a>b and a>=c):
# print("First number is big ",a)
# elif(b>c and b>=d):
# print("second is bigger",b)
# elif(c>d and c>=a):
# print("third is biiger",c)
# else:
# print("fourth is biiger",d)
# #wap to take in the , and display the grade as per following rules:
# marks=int(input("Enter your marks :"))
# if(marks >=90 ):
# grade ="A"
# elif(marks >=80 ):
# grade ="B"
# elif(marks >=70):
# grade="C"
# else:
# grade="D"
# print("Your marks is -> ",grade)
#LISTS AND TUPLES
# #overview of lists
# a=[1,2,3,4,5,"hello"]
# print(a[5])
# # Tuplessss
# tup=(1,2,3,4,3,4,4)
# tup=tup.count(4) # it count how many numbers are there in tuple
# print(tup)
# A=(2,1,3,1,2,3,)
# print(A.index(3)) # find the index number
# #DEFING OBJECTS
# class person:
# def __inti__(self,name,age):
# self.name=name
# self.age=age
# p1=person("Ashutosh",18)
# p2=person("VRUTII",18)
# print(p1.name)
# print(p1.age)
# print(p2.name)
# print(p2.age)
# DICTIONARY $ SETSS
dict={
"name": " ashutosh ",
"topics": "Dictionary",
"subjects": ["python","java","css"],
}
null_dict ={} #null orempty dictonary
null_dict["name"] = "ashutosh" # we can write in empty also or null
print(null_dict)
#for changes
dict["name"] = " ashu " #overwrite
dict[" surname"] = "Rai"
print(dict)