Code Monkey home page Code Monkey logo

Comments (3)

PRUBHTEJ avatar PRUBHTEJ commented on July 18, 2024

I like the game!!!

from dice-rolling-python.

github-learning-lab avatar github-learning-lab commented on July 18, 2024

I like the game!!!
! Wow that's a classic! You might be able to make a version of I like the game!!!
when we are done!

Running a Python file

Let's look at our Python file. Inside we see a function main that will contain all of your commands as you create the dice roller:

def main():
    #print('You rolled a die')

Below that, you'll see an if statement calling that function:

if __name__== "__main__":
    main()

By doing this, the function main will run whenever you run the Python script. As you develop the dice roller, be sure to only manipulate the code within the main function; nothing else will need to be changed.

Right now the only line in our main function is a print() function:#print('You rolled a die'). This will print whatever is inside the parenthesis. There's a # in front of it right now, which means it's a comment. Uncomment it by removing the # to let Python read it, and save the file.

You can run the Python script by typing python dice_roller.py in a terminal, provided you're in the correct directory. If not, run the script by typing python /path/to/directory/dice_roller.py, where /path/to/directory is replaced with the path to the file on your own system.

You'll see the following nifty, albeit not very useful line printed out in your terminal: "You've rolled a die". We'll make it more informative in a bit, but first, let's push those changes to GitHub.

Pushing your changes

Whenever you change files in your repository, you'll want to add and commit the file, which allows you to add a message detailing what you changed. Then you can push the updated version, along with your comments, to GitHub.

Let's do those three steps:

  1. Git Add: git add dice_roller.py
  2. Git Commit: git commit -m "I uncommented line 2"
  3. Git Push: git push

from dice-rolling-python.

github-learning-lab avatar github-learning-lab commented on July 18, 2024

Great!

You will be pushing code to your own repository several times as a reference.

Click here to for the next steps

from dice-rolling-python.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.