Comments (3)
done
from intermediate-python-course.
done! Wow that's a classic! You might be able to make a version of done 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:
- Git Add:
git add dice_roller.py
- Git Commit:
git commit -m "I uncommented line 2"
- Git Push:
git push
from intermediate-python-course.
Great!
You will be pushing code to your own repository several times as a reference.
Click here to for the next steps
from intermediate-python-course.
Related Issues (2)
- Using Variables HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intermediate-python-course.