-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHello.py
215 lines (211 loc) · 5.45 KB
/
Hello.py
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# print("Hello World")
# def main():
# print("Hello world!")
# print("Guru99")
# main()
# a = 9
# print(a)
# b = "guru99"
# print(b)
# print(str(a) + b)
# f = 101
# print(f)
# def my_func():
# f = "I am learning Python"
# print(f)
# my_func()
# print(f)
# def newVar():
# global f
# print(f)
# f = "new f"
# newVar()
# print(f)
# del f
# var1 = "Guru99"
# var2 = "Software Testing"
# print(var1[0])
# print(var2[1:5])
# print(var2[:])
# print(var1 * 2)
# x = "u" not in var1
# print(x)
# print("hi"r"\nbye")
# name = "guru"
# number = 99
# print("%s %d" % (name, number))
# print(str(number)*5)
# x = "Hello World!"
# print(x[:6])
# print(x[0:6] + "Guru99")
# print(x[0:6])
# oldstring = "I like chocolate"
# newstring = oldstring.replace("like", "love")
# print(newstring)
# print(oldstring)
# print(newstring.upper())
# print(oldstring.lower())
# # print(":".join("Python"))
# var = "12345"
# print("".join(reversed(var)))
# mystring = "dword1 dword2 dword3"
# print(mystring.split("d"))
# tup1 = ("Robert", "Carlos", "1965", "Terminator 1995", "Actor", "Florida");
# tup2 = (1, 2, 3, 4, 5, 6, 7);
# print(tup1[0])
# print(tup2[1:4])
# x = ("Guru99", "20", "Education")
# (company, emp, profile) = x
# print(company)
# print(emp)
# print(profile)
# print(x)
# a = (5, 6)
# b = (6, 4)
# if (a>b): print("a")
# else: print("b")
# Dict = {"Tim": 18, "Denise":5, "Catherine": 12, "Robert": 112}
# print(Dict["Tim"])
# Boys = {"Tim": 18, "Robert": 112}
# Girls = {"Denise":5, "Catherine": 12}
# studentY = Boys.copy()
# studentX = Girls.copy()
# print(studentX)
# print(studentY)
# Dict.update({"Sarah": 25})
# print(Dict)
# del Dict["Sarah"]
# print(Dict)
# print("Students Name: %s" % list(Dict.items()))
# for key in list(Dict.keys()):
# if key in list(Boys.keys()):
# print(True)
# else:
# print(False)
# students = list(Dict.keys())
# students.sort()
# print(students)
# for a in students:
# print(": ".join((a,str(Dict[a]))))
# print("Length: %d" % len(Dict))
# print("Type: %s" % type(Dict))
# print("Printable string: %s" % str(Dict))
# print(Dict)
# x = 4
# x += 4
# y = 5
# print("the value of x>y is", x>y)
# print("Line 1 - Value of x: ", x)
# print("Line 2 - Value of y: ", y)
# a = True
# b = False
# print("a and b is", a and b)
# print("a or b is", a or b)
# b = a
# print("new a or b is", a or b)
# print("not a is", not a)
# x = 4
# y = 8
# list = [1, 2, 3, 4, 5,]
# if (x in list):
# print("Line 1 - x is available in the given list")
# else:
# print("Line 1 - x is not available in the given list")
# if (y not in list):
# print("Line 2 - y is not available in the given list")
# else:
# print("Line 2 - y is available in the given list")
# def func1():
# print("I am learning Python Functions!!!")
# x = 5
# return(x)
# func1()
# myVar = func1()
# print(myVar)
# def square(x):
# var = x * x
# return(var)
# print(square(4))
# def bigNumber(a, b, c, d, e, f, g):
# ans = a * b * c * d * e *f *g * a **2
# return(ans)
# print(bigNumber(10, 20, 30, 40, 50, 60, 70))
# def multiply(x, y = 0):
# ans = x * y
# return(ans)
# print("only x:", multiply(5))
# print("x and y:", multiply(5, 1))
# def guru99(args):
# print(args)
# return
# myArray = (1, 2, 4, 5)
# guru99(myArray)
# def guru992(*args):
# print(args)
# return
# guru992(1,2, 4, 5)
# # Note: Why is there a pointer necessary when the function is being
# # called by directly inputting values, but when passing a predefined
# # tuple the pointer is not required and slightly changes the output?
# # (Lines 138 - 146)
# def main():
# x, y = 2, 2
# st = "x is smaller" if (x < y) else "x >= y"
# print(st)
# main()
# def switch(arg):
# switcher = {
# 0: "Zero",
# 1: "One",
# 2: "Two"
# }
# return(switcher.get(arg, "nothing"))
# print(switch(3))
# lis = "The Seasons"
# for x in lis:
# if (x == "S"): continue
# print(x)
# Months = ["jan", "feb", "mar", "apr", "may", "jun"]
# for a, b in enumerate(Months):
# print(a, b)
# for i in range(1, 124):
# print("guru99", i)
# class myClass():
# def method1(self):
# print("Guru99")
# def method2(self, someString):
# print("Software Testing: " + someString)
# class childClass(myClass):
# def method1(self):
# myClass.method1(self)
# print("childClass Method1")
# def method2(self, someString):
# myClass.method2(self, someString)
# print("childClass method2")
# def main():
# c2 = childClass()
# c2.method1()
# c2.method2("yay! It works!!!!!")
# c = myClass()
# c.method1()
# c.method2("yay! It works!!!!!")
# main()
# # Note: We said that childClass was supposed to inherit the features
# # of myClass, but then when we defined method1 in childClass we had
# # to call myClass.method1(self) in order to actually have the child
# # inherit the features. If this is necessary, why did we include
# # (myClass) in the original definition of childClass, instead of
# # simply having empty parentheses? Does inheritance automatically
# # occur by including the parent class in the definition of the child,
# # or is it something that has to be coded in?
# class User:
# def __init__(self, name, age):
# self.name = name
# self.age = age
# def sayHello(self):
# print("Welcome to Guru99, " + self.name)
# def printAge(self):
# print("Your age is " + str(self.age))
# User1 = User("Jennifer", 20)
# User1.sayHello()
# User1.printAge()