File tree Expand file tree Collapse file tree 5 files changed +93
-0
lines changed Expand file tree Collapse file tree 5 files changed +93
-0
lines changed Original file line number Diff line number Diff line change 5
5
- [ Day 1] ( https://github.com/a092devs/100-days-of-python/tree/master/day01 ) - Working with Variables in Python to Manage Data
6
6
- [ Day 2] ( https://github.com/a092devs/100-days-of-python/tree/master/day02 ) - Understanding Data Types and How to Manipulate Strings
7
7
- [ Day 3] ( https://github.com/a092devs/100-days-of-python/tree/master/day03 ) - Control FLow and Logical Operators
8
+ - [ Day 4] ( https://github.com/a092devs/100-days-of-python/tree/master/day04 ) - Randomization and Python Lists
8
9
9
10
10
11
## ⚙ Tools and Technologies Covered
Original file line number Diff line number Diff line change
1
+ # Import the random module here
2
+ import random
3
+ # Split string method
4
+ names_string = input ("Give me everybody's names, separated by a comma. " )
5
+ names = names_string .split (", " )
6
+ # 🚨 Don't change the code above 👆
7
+
8
+ # Write your code below this line 👇
9
+ length = len (names )
10
+ name_index = random .randint (0 , length - 1 )
11
+ print (f"{ names [name_index ]} is going to buy the meal today!" )
Original file line number Diff line number Diff line change
1
+ # Remember to use the random module
2
+ # Hint: Remember to import the random module here at the top of the file. 🎲
3
+
4
+ # Write the rest of your code below this line 👇
5
+ import random
6
+
7
+ coin_flip = random .randint (0 ,1 )
8
+ if coin_flip == 1 :
9
+ print ("Heads" )
10
+ else :
11
+ print ("Tails" )
Original file line number Diff line number Diff line change
1
+ import random
2
+
3
+ rock = '''
4
+ _______
5
+ ---' ____)
6
+ (_____)
7
+ (_____)
8
+ (____)
9
+ ---.__(___)
10
+ '''
11
+
12
+ paper = '''
13
+ _______
14
+ ---' ____)____
15
+ ______)
16
+ _______)
17
+ _______)
18
+ ---.__________)
19
+ '''
20
+
21
+ scissors = '''
22
+ _______
23
+ ---' ____)____
24
+ ______)
25
+ __________)
26
+ (____)
27
+ ---.__(___)
28
+ '''
29
+
30
+ game_arts = [rock , paper , scissors ]
31
+
32
+ user_choice = int (input ("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n " ))
33
+ if user_choice >= 3 or user_choice < 0 :
34
+ print ("You typed an invalid number, You Lose. ☠" )
35
+ else :
36
+ print (game_arts [user_choice ])
37
+
38
+ computer_choice = random .randint (0 , 2 )
39
+ print ("Computer chose:" )
40
+ print (game_arts [computer_choice ])
41
+
42
+ if user_choice == 0 and computer_choice == 2 :
43
+ print ("You win! 🎉" )
44
+ elif computer_choice == 0 and user_choice == 2 :
45
+ print ("You lose. ☠" )
46
+ elif computer_choice > user_choice :
47
+ print ("You lose. ☠" )
48
+ elif user_choice > computer_choice :
49
+ print ("You win! 🎉" )
50
+ elif computer_choice == user_choice :
51
+ print ("It's a draw." )
Original file line number Diff line number Diff line change
1
+ # 🚨 Don't change the code below 👇
2
+ row1 = ["⬜️" ,"️⬜️" ,"️⬜️" ]
3
+ row2 = ["⬜️" ,"⬜️" ,"️⬜️" ]
4
+ row3 = ["⬜️️" ,"⬜️️" ,"⬜️️" ]
5
+ my_list = [row1 , row2 , row3 ]
6
+ print (f"{ row1 } \n { row2 } \n { row3 } " )
7
+ position = input ("Where do you want to put the treasure? " )
8
+ # 🚨 Don't change the code above 👆
9
+
10
+ # Write your code below this row 👇
11
+ horizontal = int (position [0 ])
12
+ vertical = int (position [1 ])
13
+
14
+ my_list [vertical - 1 ][horizontal - 1 ] = "X"
15
+
16
+ # Write your code above this row 👆
17
+
18
+ # 🚨 Don't change the code below 👇
19
+ print (f"{ row1 } \n { row2 } \n { row3 } " )
You can’t perform that action at this time.
0 commit comments