Recent Posts

Pages: 1 ... 3 4 [5] 6 7 ... 9
41
100 Days of Code / Day 4 Project
« Last post by KingZimbabww on November 29, 2021, 03:31:20 am »
rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

paper = '''
    _______
---'   ____)____
          ______)
          _______)
         _______)
---.__________)
'''

scissors = '''
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
'''

#Write your code below this line 👇
import random

you = input ("What do you choose? Type 0 for Rock, 1 for Paper, or 2 for scissors. ")
you = int(you)

if you == 0:
  print (rock)
if you == 1:
  print(paper)
if you == 2:
  print(scissors)

print("Computer chooses: ")
computer = random.randint(0,2)
if computer == 0:
  print (rock)
elif computer == 1:
  print(paper)
elif computer == 2:
  print(scissors)

if you == computer:
  print("It's a draw.")
elif you == 0 and computer == 1:
  print("You win!")
elif you == 2 and computer == 1:
  print("You win!")
else:
  print("You lose!")
42
100 Days of Code / Re: Day 5 - Python Loops
« Last post by Obreh Winfrey on November 28, 2021, 09:17:41 pm »
Python makes it easy to loop over lists, but sometimes you need a traditional C-style for loop that let's you use the iteration of the loop. I did some file operations in a script where I needed to use the index to know where to markup a file. This link is a helpful tutorial: https://treyhunner.com/2016/04/how-to-loop-with-indexes-in-python/
43
100 Days of Code / Re: Day 8 - Function Parameters & Caesar Cipher
« Last post by Obreh Winfrey on November 28, 2021, 09:11:03 pm »
Pay attention to isPrime, that's a method implementation that comes up in job interviews from time to time. Prime numbers are only divisible by 1 and themselves, which allows you to shortcut some math by checking from 2 to n / 2. It's an optimization that pays off for large n. I think there's also some other mathematical trickery you can employ on that, but at that point you really aren't solving a computer science problem, but a math problem - as an interviewer I'd never expect or even want the mathematical answer.
44
100 Days of Code / Re: Day 10 - Functions with Output
« Last post by Obreh Winfrey on November 28, 2021, 08:59:22 pm »
Inputs and Outputs of a Function
Spoiler (hover to show)

Challenge
Spoiler (hover to show)

Example of a docstring
Spoiler (hover to show)

Project
Spoiler (hover to show)

I think you can condense your Is_Year_Leap_Year to a handful of lines
Spoiler (hover to show)
That's based on a quick visual inspection though, I could be wrong.
45
100 Days of Code / Re: Day 10 - Functions with Output
« Last post by Secure Da Bag on November 28, 2021, 08:36:26 pm »
Inputs and Outputs of a Function
Spoiler (hover to show)

Challenge
Spoiler (hover to show)

Example of a docstring
Spoiler (hover to show)

Project
Spoiler (hover to show)
47
100 Days of Code / Re: Day 9 - Dictionaries, Nesting and the Secret Auction
« Last post by Secure Da Bag on November 28, 2021, 06:33:40 pm »
Create a dictionary
Spoiler (hover to show)

Add a key and value
Spoiler (hover to show)

Empty dictionary
Spoiler (hover to show)

Accessing a dictionary in a for loop
Spoiler (hover to show)

Challenge
Spoiler (hover to show)

Embed a list in a dictionary
Spoiler (hover to show)

Challenge
Spoiler (hover to show)

Embed dictionaries in a list
Spoiler (hover to show)

Challenge
Spoiler (hover to show)

Project
Spoiler (hover to show)
48
100 Days of Code / Re: Day 8 - Function Parameters & Caesar Cipher
« Last post by Secure Da Bag on November 27, 2021, 12:25:16 pm »
Create a function
Spoiler (hover to show)

Function with multiple parameters
Spoiler (hover to show)

Functions with named parameters
Spoiler (hover to show)

Challenge
Spoiler (hover to show)

Challenge
Spoiler (hover to show)

Project
Spoiler (hover to show)
49
100 Days of Code / Re: Day 7 - Hangman
« Last post by Secure Da Bag on November 27, 2021, 10:00:51 am »
Challenge
Spoiler (hover to show)
50
100 Days of Code / Re: Day 6 - Python Functions & Karel
« Last post by Secure Da Bag on November 27, 2021, 10:00:01 am »
Code is not up. But completed. I strongly suggest everyone do this lesson.
Pages: 1 ... 3 4 [5] 6 7 ... 9