Skip to content

Commit 3d24d37

Browse files
committed
For Loop done
1 parent e44d6da commit 3d24d37

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

Diff for: basics/For Loop/brakeAndCondition.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# basket = ["Apple", "Banana", "Cherry"]
2+
3+
# for fruit in basket:
4+
# print(f"I ate the {fruit}")
5+
# if fruit == "Banana":
6+
# break
7+
8+
numbers = [1, 2, 3, 4, 5 ,6, 7, 8, 9, 10]
9+
10+
for number in numbers:
11+
if number % 2 == 0:
12+
print(f"{number} is even")
13+
continue #Skip one tick or step in the loop
14+
print(f"{number} is odd")

Diff for: basics/For Loop/challenge.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'''
2+
Example List
3+
4+
username = ["John","Alenere","David"]
5+
6+
password = ["abc123","123abc","hahatdog"]
7+
8+
PS the password and username are paired by index
9+
10+
John’s Password is abc123
11+
12+
Then make the user input a username and password then check if the input matches the pair of username and password
13+
14+
if account exists display “Welcome , [username]”
15+
16+
if not “Account not found”
17+
'''
18+
19+
20+
username = ["John","Alenere","David"]
21+
password = ["abc123","123abc","hahatdog"]
22+
chances = 3
23+
24+
25+
26+
while chances > 0:
27+
user = input("Enter your username: ")
28+
passw = input("Enter your password: ")
29+
print(f"Chances left: {chances}")
30+
for i in range(len(username)):
31+
if username[i] == user and password[i] == passw:
32+
print(f"Welcome {username[i]}")
33+
break
34+
else:
35+
print("Account not found")
36+
chances -= 1

Diff for: basics/For Loop/range.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for x in range(5):
2+
print(x)
3+

Diff for: draw.drawio

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<mxfile host="65bd71144e">
2+
<diagram id="oLlrVAvMdPEItwFHq-uc" name="Page-1">
3+
<mxGraphModel dx="990" dy="783" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="1700" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0"/>
6+
<mxCell id="1" parent="0"/>
7+
<mxCell id="2" value="Start" style="ellipse;whiteSpace=wrap;html=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontSize=20;" parent="1" vertex="1">
8+
<mxGeometry x="250" y="90" width="120" height="80" as="geometry"/>
9+
</mxCell>
10+
<mxCell id="22" style="edgeStyle=none;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontSize=16;" edge="1" parent="1">
11+
<mxGeometry relative="1" as="geometry">
12+
<mxPoint x="610" y="385" as="sourcePoint"/>
13+
<mxPoint x="770" y="530" as="targetPoint"/>
14+
<Array as="points">
15+
<mxPoint x="770" y="385"/>
16+
</Array>
17+
</mxGeometry>
18+
</mxCell>
19+
<mxCell id="31" style="edgeStyle=none;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=1;entryY=0.75;entryDx=0;entryDy=0;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontSize=16;" edge="1" parent="1">
20+
<mxGeometry relative="1" as="geometry">
21+
<mxPoint x="770" y="590" as="sourcePoint"/>
22+
<mxPoint x="556.1538461538462" y="701.5384615384614" as="targetPoint"/>
23+
</mxGeometry>
24+
</mxCell>
25+
<mxCell id="27" value="False" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontSize=20;" vertex="1" parent="1">
26+
<mxGeometry x="640" y="340" width="60" height="30" as="geometry"/>
27+
</mxCell>
28+
<mxCell id="33" value="End" style="ellipse;whiteSpace=wrap;html=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontSize=20;" vertex="1" parent="1">
29+
<mxGeometry x="440" y="800" width="120" height="80" as="geometry"/>
30+
</mxCell>
31+
</root>
32+
</mxGraphModel>
33+
</diagram>
34+
</mxfile>

0 commit comments

Comments
 (0)