Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df0bcd2

Browse files
test
1 parent f0affe2 commit df0bcd2

18 files changed

+550
-0
lines changed
636 Bytes
Binary file not shown.
1.2 KB
Binary file not shown.

calculator.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def add(a,b):
2+
return a + b
3+
4+
def subtract(a,b):
5+
return a - b
6+
7+
def multiply(a,b):
8+
return a * b
9+
10+
def divide(a,b):
11+
return a // b

conditional_statements.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#if elif else
2+
num = 10
3+
if num % 2 == 0:
4+
print("Even")
5+
else:
6+
print("Odd")
7+
8+
marks = 60
9+
if marks >= 90:
10+
print("Grade A")
11+
elif marks < 90 and marks >= 75:
12+
print("Grade B")
13+
elif marks < 75 and marks >= 60:
14+
print("Grade C")
15+
else:
16+
print("Grade D")
17+

datatypes.py

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#mutable list, set, dictionary
2+
#immutabe tuple string , all primitive datatptes(int, float,bool)
3+
l1 = []
4+
# l1 = list()
5+
l1.append(1)
6+
print(l1) # [1]
7+
l1.append(2)
8+
print(l1) # [1,2]
9+
10+
l1.extend([4,5])
11+
print(l1) # [1,2,4,5]
12+
13+
l1.insert(2,3) # [1,2,3,4,5]
14+
15+
# Removal
16+
l1.remove(3)
17+
print(l1) # [1,2,4,5]
18+
19+
remved_element = l1.pop() # [1,2,4]
20+
# remved_element = 5
21+
removed_element = l1.pop(0) # [2,4]
22+
# # remved_element = 1
23+
24+
del l1[1]
25+
26+
l1 = [1,3,4,5,2,6]
27+
l1.sort() # [1,2,3,4,5,6]
28+
l1.sort(reverse=True)
29+
30+
for num in l1:
31+
print(num)
32+
33+
l1 = [1,2,3]
34+
for num in l1:
35+
print(num*num)
36+
#1
37+
#4
38+
#9
39+
l1 = [1,2,3,2]
40+
l1.count(2) # 2
41+
42+
l1.clear() # []
43+
44+
l1 = [1,2,3,4]
45+
l1.reverse() # [4,3,2,1]
46+
47+
l1 = [1,2,3]
48+
l2 = [4,5,6]
49+
l3 = l1 + l2 # l3 = [1,2,3,4,5,6]
50+
l1.extend(l2) # l4 = [1,2,3,4,5,6]
51+
52+
l1 = [1] * 10 # l1 = [1,1,1,1,1,1,1,1,1,1]
53+
print(l1)
54+
55+
l1 = [1,2,3,4] #[0,1,2,3]
56+
print(l1[0])
57+
58+
# Set
59+
s1 = {1,2,3} # 1-> 100 2-> 200
60+
print(s1)
61+
s1.add(4) # {1,2,3,4}
62+
s1.update([5,6]) # {1,2,3,4,5,6}
63+
s1.remove(5) # {1,2,3,4,6}
64+
s1.discard(6) #{1,2,3,4,6}
65+
s1 = {1,2,3}
66+
s2 = {2,3,4}
67+
s3 = s1.intersection(s2) # {2,3}
68+
s3 = s1 & s2
69+
s3 = s1.union(s2) # {1,2,3,4}
70+
s3 = s1 ^ s2 #
71+
s4 = s1 - s2 # {1}
72+
s5 = s2 - s1 # {4}
73+
s1.difference(s2) # {1}
74+
s2.difference(s1) # {4}
75+
s1.clear() # remove all the elements s1 = {}
76+
77+
# dictionary
78+
# d1 = {'id': 1, 'name': 'ABC'}
79+
d1 = dict()
80+
d1['id'] = 1
81+
d1['name'] = 'ABC'
82+
print(d1)
83+
d1.update({'age':26,'salary':34000})
84+
print(d1)
85+
86+
d1.pop('id')
87+
print(d1)
88+
removed_item = d1.popitem()
89+
print(removed_item)
90+
print(d1)
91+
# d1.clear() # {}
92+
print(d1.keys())
93+
print(d1.values())
94+
print(d1.items())
95+
for key, value in d1.items(): # key = id, value=1
96+
print(f"Key: {key} Value: {value}") # "Key: id Value: 1"
97+
98+
d2 = {'id': 1, 'name': 'ABC', 'age': 26, 'salary': 34000}
99+
# print(d1['id']) # 1
100+
dept = d1.get('dept',None) # None
101+
102+
# Tuple -> Immutable data type
103+
t1 = (1,2,3)
104+
t1[0] = 100
105+
for num in t1:
106+
print(num)
107+
#1
108+
#2
109+
#3
110+
t1.count(1) # 1
111+
t1.index(3) # 2
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+

functions.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Simple function to print a greeting message
2+
def greet():
3+
print("Hello, World!")
4+
5+
greet()
6+
7+
# Parameterized function
8+
def add(a, b):
9+
result = a + b
10+
print(result)
11+
12+
add(10, 10)
13+
14+
# Parameterized function with return value
15+
def full_name(first_name, last_name):
16+
result = first_name + " " + last_name
17+
return result
18+
result = full_name("Ramesh", "Ravuri")
19+
print(result) # Ramesh Ravuri
20+
21+
# Function with default parameter
22+
def area_of_circle(radius, pi=3.14):
23+
area = pi * radius * radius
24+
return area
25+
26+
result = area_of_circle(5)
27+
print(result)
28+
result = area_of_circle(10,pi=3.18)
29+
print(result) # 314.0
30+
31+
# Function with variable number of arguments and keyword arguments
32+
def catch_args_kwargs(*args, **kwargs):
33+
print(args) # (1, 2, 3, 4, 5)
34+
print(kwargs) # {'a': 1, 'b': 2, 'c': 3}
35+
catch_args_kwargs(1, 2, 3, 4, 5, a=1, b=2, c=3)
36+
37+
def sum_numbers(*args): # (1,2,3)
38+
result = 0
39+
for num in args:
40+
result += num
41+
return result
42+
numbers = list(range(1,101))
43+
result = sum_numbers(*numbers) # 15sum_numbers(1,2,3,4,5..100)
44+
print(result)
45+
46+
num = 10
47+
simple_lambda = lambda : "Hello World"
48+
print(simple_lambda()) # Hello World
49+
50+
full_name = lambda first_name, last_name: first_name + " " + last_name
51+
print(full_name("Ramesh", "Ravuri")) # Ramesh Ravuri
52+

inbuilt_functions.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Mathematical Functions
2+
3+
print(abs(-10))
4+
5+
print(min([1,2,3,200,302,400])) # 1
6+
7+
print(max([1,2,3,200,302,400])) # 400
8+
9+
print(sum([10,10,10])) # 30
10+
11+
print(round(10.6789)) # 11
12+
print(round(10.6789,2)) # 10.68
13+
14+
print(pow(2,4)) # 16 # 2 ** 4
15+
16+
print(divmod(10,3)) # (3,1) # 10//3, 10%3
17+
18+
print(int('10')) # 10
19+
print(float('10.5')) # 10.5
20+
print(str(10)) # '10'
21+
print(bool(10)) # True
22+
print(bool(0)) # False
23+
print(bool('')) # False
24+
25+
l1 = [1,2,3]
26+
t1 = tuple(l1)
27+
28+
t2 = (1,2,3)
29+
l2 = list(t2)
30+
31+
l1 = [1,2,3,3,4,5,6,7,8,9]
32+
s1 = set(l1) # {1,2,3,4,5,6,7,8,9}
33+
34+
d1 = dict(a=1,b=2,c=3) # {'a': 1, 'b': 2, 'c': 3}
35+
keys = ['name', 'age']
36+
values = ['Ramesh', 30]
37+
d2 = dict(zip(keys, values)) # {'name': 'Ramesh', 'age': 30}
38+
d2 = dict((('name', 'Ramesh'), ('age', 30))) # {'name': 'Ramesh', 'age': 30}
39+
40+
print(eval('10+20-20')) # 10
41+
print(any([False, False, False])) # False
42+
print(any([True, False, False])) # True
43+
print(all([True, True, False])) # False
44+
print(all([True, True, True])) #
45+
46+
print(chr(65)) # A
47+
print(chr(97)) # a
48+
print(ord('A')) # 65
49+
print(ord('a')) # 97
50+
51+
print(bin(10)) #

intro.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Python is a high-level, interpreted programming language known for
2+
its simplicity, readability.
3+
It was created by Guido van Rossum and first released in 1991.
4+
5+
Key Features:
6+
7+
Easy to Learn and Read: Uses clear, English-like syntax.
8+
9+
Interpreted Language: Code runs line-by-line, no need for compilation.
10+
11+
Dynamically Typed: You don’t need to declare variable types explicitly.
12+
13+
Multi-paradigm: Supports object-oriented, procedural, and functional programming.
14+
15+
Large Standard Library: Comes with built-in modules for file I/O, math, web services, etc.
16+
17+
Cross-platform: Works on Windows, Linux, macOS, etc.
18+
19+
Extensible: Can be integrated with C/C++, Java, etc.
20+
21+
Common Uses:
22+
Web Development (e.g., Django, Flask)
23+
24+
Data Science & Machine Learning (e.g., pandas, NumPy, scikit-learn, TensorFlow)
25+
26+
Automation & Scripting
27+
28+
Desktop Applications
29+
30+
Game Development
31+
32+
Internet of Things (IoT)

loops.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#while
2+
#for
3+
# break, continue, pass
4+
for num in [1,2,3,4,5]:
5+
print(num) # 1 2 3 4 5
6+
for num in set([1,2,3,4,5]):
7+
print(num) # 1 2 3 4 5
8+
for key, value in {'a': 1, 'b': 2}.items():
9+
print(key, value) # a 1 b 2
10+
11+
l1 = [1000,2000,3000,4000,5000]
12+
print(list(range(0,100))) # 0-99
13+
print(list(range(100)))
14+
print(list(range(0,100,2))) # 0-98
15+
index = 0
16+
while index < 100:
17+
print(index)
18+
index += 1 # index = index + 1
19+
#0-99
20+
index = 0
21+
while index < 100:
22+
print(index)
23+
index += 2 # index = index + 1
24+
# 0-98
25+
26+
while True:
27+
agent = input("Enter agent message: ")
28+
if agent == "exit":
29+
break
30+
customer = input("Enter customer message: ")
31+
if customer == "exit":
32+
continue
33+
print(f"Agent: {agent}")
34+
print(f"Customer: {customer}")
35+
36+

operators.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Arithmetic Operators
2+
#+, -, *, /, //, %, **
3+
a = 10
4+
b = 20
5+
print(a+b)
6+
print(b-a)
7+
print(a*b)
8+
print(b/a) # 2.0000
9+
print(b//a) # Floor division # 2
10+
print(b%a) # Modulus #0
11+
print(2**2) # 4
12+
print(3 % 5) # 3
13+
14+
15+
# Comparison Operators
16+
# ==, !=, >, <, >=, <=
17+
a = 'abc'
18+
b = 'abc'
19+
print(a == b) # True
20+
a = 10
21+
b = 20
22+
print(a != b) # True
23+
print(a > b) # False
24+
print(a < b) # True
25+
print(a <= b) # True
26+
print(a >= b) # False
27+
28+
# Logical Operators
29+
# and, or, not
30+
31+
a = 10
32+
b = 20
33+
print(a > 5 and b < 30) # True
34+
print(a > 30 or b < 10) # True
35+
print(not (a<20)) # False
36+
37+
# Assignment Operators
38+
# =, +=, -=, *=, /=, //=, %=, **=
39+
a = 10
40+
a = a + 5
41+
a += 5 # a = a + 5
42+
a -= 5 # a = a - 5
43+
a *= 5 # a = a * 5
44+
a /= 5 # a = a / 5
45+
a //= 5 # a = a // 5
46+
a %= 5 # a = a % 5
47+
a **= 5 # a = a ** 5
48+
49+
# Membership Operators
50+
# in, not in
51+
l1 = [1,2,3,4,5]
52+
print(4 in l1) # True
53+
print(6 in l1) # False
54+
print(4 not in l1) # False
55+
print(6 not in l1) # True
56+
57+
#Identity Operators
58+
# is, is not
59+
l1 = [1,2,3]
60+
l2 = [1,2,3]
61+
print(l1 == l2) # True, because the values are same
62+
print(id(l1), id(l2))
63+
print(l1 is l2) # True
64+
print(l1 is not l2) # False, because the values are same

0 commit comments

Comments
 (0)