Skip to content

Commit 5aafdaf

Browse files
Merge pull request #5 from PavanMudigondaTR/dev
updated
2 parents 1f09c77 + 1cf5715 commit 5aafdaf

13 files changed

Lines changed: 180 additions & 7 deletions

File tree

34-args-kwargs/another_way.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11

2-
def show_kwargs_details(**kwargs):
2+
# *args = allows you to pass multiple non-keyword arguments
3+
# **kwargs = allows you to pass multiple keyword arguments
4+
# * and ** are unpacking operators
5+
# Argument types:
6+
# 1. positional
7+
# 2. default
8+
# 3. keyword
9+
# 4. arbitrary
10+
11+
12+
313
# Show all keys
414
print("Keys:")
515
for key in kwargs.keys():

34-args-kwargs/shipping_labels.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# *args = allows you to pass multiple non-keyword arguments
3+
# **kwargs = allows you to pass multiple keyword arguments
4+
# * and ** are unpacking operators
5+
# Argument types:
6+
# 1. positional
7+
# 2. default
8+
# 3. keyword
9+
# 4. arbitrary
10+
11+
12+
def shipping_label(*args,**kwargs):
13+
for arg in args:
14+
print(arg, end=" ")
15+
print("\n")
16+
# for key,value in kwargs.items():
17+
# print(f'{key} : {value}')
18+
if "apt" in kwargs:
19+
print(f'{kwargs.get('apt')} - {kwargs.get('street_number')} {kwargs.get('street_name')}')
20+
else:
21+
print(f'{kwargs.get('street_number')} {kwargs.get('street_name')}')
22+
print(f'{kwargs.get('city')} , {kwargs.get('state')} , {kwargs.get('postal_code')}')
23+
shipping_label("Dr", "Spongebob", "Squarepants", "III",
24+
street_number="123",
25+
street_name="Front St",
26+
apt="1301",
27+
city="Toronto",
28+
state="ON",
29+
postal_code="M5V3A4")

35-iterables/dict.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Iterables
2+
# # Iterables = An object/collection that can return its elements one at a time.
3+
# allowing it to be iterated over in a loop
4+
5+
6+
my_dictionary = { "A": "1",
7+
"B": "2",
8+
"C": "3",
9+
"D": "4",
10+
"E": "5",
11+
"F": "6",
12+
"G": "7",
13+
}
14+
15+
for key, value in my_dictionary.items():
16+
print(f'{key} : {value}')

35-iterables/fruits.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Iterables
2+
# # Iterables = An object/collection that can return its elements one at a time.
3+
# allowing it to be iterated over in a loop
4+
5+
6+
# Lists can be reversed
7+
# Sets can't be reversed
8+
# Tuple can be reversed
9+
10+
# List
11+
# fruits = ["apple", "orange", "banana", "strawberry", "blueberry" "coconut"]
12+
13+
# Set
14+
# fruits = { "apple", "orange", "banana", "strawberry", "blueberry" "coconut" }
15+
16+
# Tuple
17+
fruits = ("apple", "orange", "banana", "strawberry", "blueberry" "coconut")
18+
19+
# for fruit in fruits:
20+
# print(fruit)
21+
22+
for fruit in reversed(fruits):
23+
print(fruit)

35-iterables/main.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

35-iterables/names.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Iterables
2+
# # Iterables = An object/collection that can return its elements one at a time.
3+
# allowing it to be iterated over in a loop
4+
5+
6+
name = "Bro Code"
7+
8+
for char in name:
9+
print(char,end=" ")

35-iterables/numbers.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Iterables
2+
# # Iterables = An object/collection that can return its elements one at a time.
3+
# allowing it to be iterated over in a loop
4+
5+
# Lists can be reversed
6+
# Sets can't be reversed
7+
# Tuple can be reversed
8+
9+
# numbers = ["1","2","3","4","5"]
10+
11+
numbers = ("1","2","3","4","5")
12+
13+
# numbers = { "1","2","3","4","5" }
14+
15+
16+
# for number in numbers:
17+
# print(number)
18+
19+
20+
for number in reversed(numbers):
21+
print(number)
22+
23+

36-membership-operators/email.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Membership Operators = used to test whether a value or variable is found in sequence
2+
# (string, list, tuple, set or dictionary)
3+
# 1. in
4+
#. 2. not in
5+
6+
7+
email = "BroCode@gmail.com"
8+
9+
if '@' in email and '.' in email:
10+
print("valid email")
11+
else:
12+
print("invalid email")

36-membership-operators/grades.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Membership Operators = used to test whether a value or variable is found in sequence
2+
# (string, list, tuple, set or dictionary)
3+
# 1. in
4+
#. 2. not in
5+
6+
7+
grades = { "Sandy" : "A",
8+
"Mandy" : "B",
9+
"Teddy" : "C",
10+
"Maddy" : "D",
11+
"Randy" : "E",
12+
"Patty" : "F" }
13+
14+
student = input("Enter the name of the student to loop of grade: ")
15+
16+
if student in grades:
17+
print(f"{student}'s grade is {grades[student]}")
18+
else:
19+
print(f'{student} not found')

36-membership-operators/main.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)