Skip to content

Commit c4b41f7

Browse files
Merge pull request #6 from PavanMudigondaTR/dev
Dev
2 parents 5aafdaf + a4e4bbd commit c4b41f7

10 files changed

Lines changed: 180 additions & 7 deletions

File tree

37-list-comprehensions/fruits.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# List Comprehensions = A concise way to create lists of python
2+
#. Compact and easier to read than traditional loops
3+
# [expression for value in iterable if condition ]
4+
5+
6+
fruits = ["apple","orange","banana","coconut"]
7+
8+
fruit_chars = [ fruit[0] for fruit in fruits ]
9+
10+
print(fruit_chars)
11+

37-list-comprehensions/grades.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# List Comprehensions = A concise way to create lists of python
2+
#. Compact and easier to read than traditional loops
3+
# [expression for value in iterable if condition ]
4+
5+
6+
grades = ["80","95","67","58","77","63"]
7+
8+
# passing_grades = [ expression for value in iterable if condition]
9+
10+
passing_grades = [ grade for grade in grades if int(grade) >= 60 ]
11+
12+
print(passing_grades)

37-list-comprehensions/main.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
# List Comprehensions
1+
# List Comprehensions = A concise way to create lists of python
2+
#. Compact and easier to read than traditional loops
3+
# [expression for value in iterable if condition ]
4+
5+
6+
# doubles = []
7+
8+
# for x in range(1,11):
9+
# doubles.append(x * 2)
10+
11+
# print(doubles)
12+
13+
# doubles = [ expression for value in iteratable if condition ]
14+
15+
doubles = [ x * 2 for x in range(1,11)]
16+
triples = [ y * 3 for y in range(1,11)]
17+
squares = [ z * 4 for z in range(1,11)]
18+
pentas = [ a * 5 for a in range(1,11)]
19+
print(doubles)
20+
print(triples)
21+
print(squares)
22+
print(pentas)

37-list-comprehensions/numbers.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# List Comprehensions = A concise way to create lists of python
2+
#. Compact and easier to read than traditional loops
3+
# [expression for value in iterable if condition ]
4+
5+
6+
numbers = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]
7+
8+
positive_nums = [num for num in numbers if num >= 0 ]
9+
negative_nums = [num for num in numbers if num <= 0 ]
10+
even_nums = [ num for num in numbers if num % 2 == 0]
11+
odd_nums = [ num for num in numbers if ((num >= 0) and (num % 2 != 0))]
12+
print(f"positive number: {positive_nums}")
13+
print(f"negative number: {negative_nums}")
14+
print(f"even number: {even_nums}")
15+
print(f"odd number: {odd_nums}")

38-match-case-statements/main.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,58 @@
1-
# Match-Case Statements
1+
# Match-Case Statements (switch): An alternate to using many 'elif' statements
2+
# Execute some code if a value matches a 'case'
3+
#. Benefits: cleaner and syntax is more readable
4+
5+
6+
# def day_of_week(day):
7+
# if day == 1:
8+
# return "Its a monday"
9+
# elif day == 2:
10+
# return "Its a tuesday"
11+
# elif day == 3:
12+
# return "Its a wednesday"
13+
# elif day == 4:
14+
# return "Its a thursday"
15+
# elif day == 5:
16+
# return "its a friday"
17+
# elif day == 6:
18+
# return "its a saturday"
19+
# elif day == 7:
20+
# return "its a sunday"
21+
# else:
22+
# return "Not a valid day"
23+
24+
# print(day_of_week(1))
25+
26+
27+
# def day_of_week(day):
28+
# match day:
29+
# case 1:
30+
# return "Its a monday"
31+
# case 2:
32+
# return "Its a tuesday"
33+
# case 3:
34+
# return "Its a wednesday"
35+
# case 4:
36+
# return "Its a thursday"
37+
# case 5:
38+
# return "its a friday"
39+
# case 6:
40+
# return "its a saturday"
41+
# case 7:
42+
# return "its a sunday"
43+
# case 8:
44+
# return "Not a valid day"
45+
46+
# print(day_of_week(1))
47+
48+
49+
def day_of_week(day):
50+
match day:
51+
case "Saturday" | "Sunday":
52+
return True
53+
case "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday":
54+
return False
55+
case _:
56+
return False
57+
58+
print(day_of_week("Monday"))
844 Bytes
Binary file not shown.
649 Bytes
Binary file not shown.

39-modules/example.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Modules = a file containing code you want to include in your program
2+
# use 'import' to include a module (built-in or your own)
3+
#. useful to break up a large program reusable separate files
4+
5+
# import math as m
6+
7+
import math
8+
9+
# print(math.pi)
10+
11+
# print(math.pow(2,2))
12+
13+
# print(math.sqrt(9))
14+
15+
# a, b, c, d, e =1, 2, 3, 4, 5
16+
17+
# print(math.e ** a)
18+
19+
20+
pi = math.pi
21+
22+
def square(x):
23+
return x ** 2
24+
25+
def cube(x):
26+
return x ** 3
27+
28+
def circumference(radius):
29+
return 2 * math.pi * radius
30+
31+
def area(radius):
32+
return math.pi * radius ** 2

39-modules/main.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
1-
# Modules
1+
#.........................main.py...............................
2+
3+
# module = a file containing code you wnat to incldue in your program
4+
#. use 'import' to include a module (built in or your own)
5+
# useful to break up a large program reusable separate files
6+
7+
import example
8+
9+
result = example.pi
10+
print(result)
11+
12+
square_value = example.square(3)
13+
14+
print(f"square value: {square_value}")
15+
16+
cube_value = example.cube(3)
17+
18+
print(f"cube value: {cube_value}")
19+
20+
circumference_value = example.circumference(3)
21+
22+
print(f"circumference value: {circumference_value}")
23+
24+
area_value = example.area(4)
25+
26+
print(f"area value: {area_value}")

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
## 📊 Progress Status
44

5-
![Progress](https://img.shields.io/badge/Progress-36%2F77-blue?style=for-the-badge)
6-
![Completion](https://img.shields.io/badge/Completion-46.7%25-green?style=for-the-badge)
5+
![Progress](https://img.shields.io/badge/Progress-40%2F77-blue?style=for-the-badge)
6+
![Completion](https://img.shields.io/badge/Completion-52%25-green?style=for-the-badge)
77

8-
**Programs Completed:** 36 out of 77
8+
**Programs Completed:** 40 out of 77
99

1010
```
11-
███████████████░░░░░░░░░░░░░░░ 46.7%
11+
███████████████░░░░░░░░░░░░░░░ 52.0%
1212
```
1313

1414
---

0 commit comments

Comments
 (0)