Skip to content

Commit 90b33f3

Browse files
committed
Modifying a List
0 parents  commit 90b33f3

14 files changed

+106
-0
lines changed

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/PythonFundamentals.iml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

function/__init__.py

Whitespace-only changes.

function/countList.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
groceries = ["apples", "bananas", "bread", "milk", "eggs", "cheese", "tomatoes", "lettuce", "chicken", "rice"]
3+
4+
print(len(groceries))
5+
6+
#
7+
print(groceries.index("bread"))

function/min_max_function.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
groceries_cost = [200, 350, 360, 380]
2+
3+
def maxCustom(groceries_cost):
4+
max_cost = 0
5+
for cost in groceries_cost:
6+
if cost > max_cost:
7+
max_cost = cost
8+
return max_cost
9+
10+
# Built-in function
11+
print("The max is " , max(groceries_cost))
12+
print("The min is ", min(groceries_cost))
13+
14+
#custom function
15+
print(maxCustom(groceries_cost))

list/__init__.py

Whitespace-only changes.

list/add_list.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
groceries = ["apples", "bananas", "bread", "milk", "eggs", "cheese", "tomatoes", "lettuce", "chicken", "rice"]
3+
4+
# BY SINGLE ADDITION
5+
groceries.append("grapes")
6+
groceries.append("strawberries")
7+
8+
# BY BATCH ADDITION
9+
groceries.extend(["grapes", "strawberries"])
10+
11+
print(groceries)

list/delete_list.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
groceries = ["apples", "bananas", "bread", "milk", "eggs", "cheese", "tomatoes", "lettuce", "chicken", "rice"]
3+
4+
del groceries[-1]
5+
6+
print(groceries)

list/list.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
groceries = ["apples", "bananas", "bread", "milk", "eggs", "cheese", "tomatoes", "lettuce", "chicken", "rice"]
3+
4+
groceries[0:2] = ["grapes", "strawberries"]
5+
6+
print(groceries)

main.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This is a sample Python script.
2+
3+
# Press Shift+F10 to execute it or replace it with your code.
4+
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
5+
6+
7+
def print_hi(name):
8+
# Use a breakpoint in the code line below to debug your script.
9+
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
10+
11+
12+
# Press the green button in the gutter to run the script.
13+
if __name__ == '__main__':
14+
print_hi('PyCharm')
15+
16+
# See PyCharm help at https://www.jetbrains.com/help/pycharm/

0 commit comments

Comments
 (0)