Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
About
People
Publications
Teaching
Resources
Research Blog
Wiki Functions
Recent changes
Help
Licensing
Page
Discussion
Edit
View history
Editing
DS4UX (Spring 2016)/Day 1 tutorial
(section)
From CommunityData
Jump to:
navigation
,
search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Output== [[File:Pacman.png|100px]] Notice how if you type a 4 and hit enter, the Python interpreter spits a 4 back out: 4 But if you assign 4 to a variable, nothing is printed: x = 4 You can think of it as that something needs to get the output. Without an assignment, the winner is the screen. With assignment, the output goes to the variable. You can reassign variables if you want: x = 4 x x = 5 x Sometimes reassigning a variable is an accident and causes bugs in programs. x = 3 y = 4 x * y x * x 2 * x - 1 * y Order of operations works pretty much like how you learned in school. If you're unsure of an ordering, you can add parentheses like on a calculator: (2 * x) - (1 * y) Note that the spacing doesn't matter: x = 4 and x=4 are both valid Python and mean the same thing. (2 * x) - (1 * y) and (2*x)-(1*y) are also both valid and mean the same thing. You should strive to be consistent with whatever spacing you like or a job requires, since it makes reading the code easier. You aren't cheating and skipping typing these exercises out, are you? Good! :)
Summary:
Please note that all contributions to CommunityData are considered to be released under the Attribution-Share Alike 3.0 Unported (see
CommunityData:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:
Cancel
Editing help
(opens in new window)
Tools
What links here
Related changes
Special pages
Page information