Skip to content

Instantly share code, notes, and snippets.

@natewalck
Created May 21, 2013 15:43
Show Gist options
  • Save natewalck/5620829 to your computer and use it in GitHub Desktop.
Save natewalck/5620829 to your computer and use it in GitHub Desktop.
Examples for Practical Python for Mac Admins
# Numbers
number1 = 7
number2 = .256
number3 = -1024
number1 + number2 + number3
number1 < number2
number2 == number3
# Strings
string1 = "Hello world"
string2 = '''Lorem ipsum dolor sit
amet, consectetur adipisicing
elit, sed do eiusmod tempor
incididunt ut labore et
dolore magna aliqua.'''
string3 = u'1024 \u00D7 768'
print(string3)
string1 + string3
string1 * 3
string1.lower()
string2.split()
string1.find('Hello')
string1.count('l')
string1.isupper()
string1.split()
string1.strip()
# Random Python Fun
substitute_this = 'goes here'
print('Some text %s' % substitute_this)
greeting = "Hello"
print "%s, how do you do?" % greeting
"Then, shalt thou count to %.2f." % (1 + 1 + 1)
fruit = ["apple", "banana", "orange"]
conferences = {'State College': 'PA', 'Los Angeles': 'CA', 'San Francisco': 'CA', 'Gothenburg': 'SE'}
len(string2)
len(fruit)
len(conferences)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment