Created
January 19, 2017 01:44
-
-
Save Kamori/cbd685bba63ad67b47db9dd0bea6fe18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prompt for a name | |
name = raw_input('Give me a name: ') | |
# output of name | |
print name | |
### | |
# Print name in a string | |
### | |
# Bad practice, hard to read | |
print 'Hello' + name | |
# Better but getting phased out | |
print 'Hello %s nice to meet you' % name | |
# My preferred | |
print 'Hello there {0}. Nice weather'.format(name) | |
# However you can be more verbose | |
another_variable = 'Tom' | |
print 'Hey {otherperson}, look its {coder}!'.format(otherperson=another_variable, coder=name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prompt for a name | |
name = input('Give me a name: ') | |
# output of name | |
print(name) | |
### | |
# Print name in a string | |
### | |
# Bad practice hard to read | |
print('Hello' + name) | |
# Better but getting phased out | |
print('Hello %s nice to meet you') % name | |
# My preferred | |
print('Hello there {0}. Nice weather').format(name) | |
# However you can be more verbose | |
another_variable = 'Tom' | |
print('Hey {otherperson}, look its {coder}!').format(otherperson=another_variable, coder=name) | |
# New in 3.6 | |
print(f'Hey {name}') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment