Hi fellow Programmers,
Today I've finally managed to get things squared away with Python and got some experience with starting a project or two!
One of the fun things and best ways for me to learn, as well as many others from what it seems like, is just diving right in and getting to starting to write and develop some projects. Writing computer code isn't easy but when you get experience with it, it's like anything it gets easier as time goes on.
I've been able to sit down and spend some more time lately going through Python and trying to learn what to do so I can get better at it. I know that there are things that I can do to get better and one of the main things is getting exposure and trying to build guided projects! There is a lot of things on the internet to help guide you along which is incredible. Let's dive into some of the small projects I decided to give a whirl and how they turned out!
All of the projects I've been doing can be found on this website here: https://www.dataquest.io/blog/python-projects-for-beginners/
Rock, Paper, Scissors
The first project that I ended up doing was a nice Rock Paper Scissors type game. This one was pretty basic and interesting to learn to write. This ended up being one that was straight forward and fairly easy to program. The guides walk you through each of the steps needed to perform which is very helpful. The one tricky part is that you need to preferably have a Python IDE installed on your computer. I'm personally using PyCharm to do all of this. I know there are lots of different programs that can be used and I can't remember why I chose PyCharm specifically but it's pretty user friendly and intuitive.
The code that I used can be seen below. I am glad have figured out how to include code snippets with Markdown. I know I'm not very good at coding yet but I remember when I first saw these types of things, I was intimidated! Thankfully, it's pretty great to spend time going through the steps needed and figuring out any missteps.
from random import randint #create a list of play options t = ["Rock", "Paper", "Scissors"] #assign a random play to the computer computer = t[randint(0,2)] #set player to False player = False while player == False: #set player to True player = input("Rock, Paper, Scissors?") if player == computer: print("Tie!") elif player == "Rock": if computer == "Paper": print("You lose!", computer, "covers", player) else: print("You win!", player, "covers", computer) elif player == "Paper": if computer == "Scissors": print("You lose!", computer, "cut", player) else: print("You win!", player, "covers", computer) elif player == "Scissors": if computer == "Rock": print("You lose...", computer, "smashes", player) else: print("You win!", player, "cut", computer) else: print("That's not a valid play. Check your spelling!") #player was set to True, but we want it to be False so the loop continues player = False computer = t[randint(0,2)]
It took a bit for me to figure out how to create a new section so that I could start a new program. There are different components to it all, projects and files are the two big points. I had to figure out how to create a new file and specify that I was going to be using Python. Check!
Number Guessing Game
No my name isn't Scott, although it is one of the names that I don't find annoying lol. This game here was fun and pretty good to program! I had some missteps with this that came with me not following all of the instructions to the T. The program ran successfully but there were a few issues. We can see that I forgot to define the variable for number of guesses. That was the first and most obvious issue since it was highlighted in red.
I figured out my mistake there and corrected it, now it was time to fix the formatting around the "player name" section so that it pulls the right information. I put an extra pair of quotation marks than I needed so I had to remove that and fix the lack of a space.
Got that fixed as well and I was happy with the results! The final line is one I would like to eventually figure out how to remove since in a finished product, I don't think people want to see that information there. I have some other small formatting critiques but I am really happy with the end result!
Here is the code I used to write the program, if anyone is interested.
import random number = random.randint(1,10) player_name = input("Hello, What's your name?") number_of_guesses = 0 print('Okay! ' + player_name+ ' I am guessing a number between 1 and 10:') while number_of_guesses < 5: guess = int(input()) number_of_guesses += 1 if guess < number: print('Your number is too low') if guess > number: print('Your guess is too high') if guess == number: break if guess == number: print('You guessed the right number in '+str(number_of_guesses) + ' tries!') else: print('You did not guess the number, the number was '+ str(number))
All of the code I wrote in the post here is self-guided and not entirely my own. I think that it's certainly an improvement but I would like to eventually figure out how to write some basic code of my own that's entirely my own!
Do you want to get paid, in crypto, for searching the internet? Try using and signing up for Presearch to earn some great crypto! I've currently got 2,470 PRE tokens, with a market value of $59.28. It doesn't sound like a lot but when you search using sites like Google you get paid $0! Join Presearch to break Google's stranglehold on the internet searches. If you'd like to sign up, use my referral link!