Some good resources to learn Python
https://unidata.github.io/online-python-training/
This page demonstrates Python tips and tricks that I use in my everyday programming as an atmospheric science graduate student.
-Brian Blaylock
Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts
Thursday, July 7, 2016
Tuesday, September 15, 2015
CHPC Python Tutorial
Python Style Guide:
http://legacy.python.org/dev/peps/pep-0008/
Python Lectures:
https://gitlab.chpc.utah.edu/u0253283/Python-Lectures
Converting tuple to a list
>>a = (1,2,3,4) # this is a tuple
>>
>>c = list(a) # this will convert the tuple to a list
>>
>>type(c)
List
>>print c
[1,2,3,4]
String output, this is good for concatenating strings with variable names with numbers. Use this for plot titles and such rather than using the '+' indicator
print('print the numbers in this string here: {0}, here {1}, and here {2}.'.format(8,7,6))
As opposed to:
print 'print the numbers in this string here: ' +str(8)+', here '+ star(7)+', and here '+ str(s)+'.'
http://legacy.python.org/dev/peps/pep-0008/
https://gitlab.chpc.utah.edu/u0253283/Python-Lectures
Converting tuple to a list
>>a = (1,2,3,4) # this is a tuple
>>
>>c = list(a) # this will convert the tuple to a list
>>
>>type(c)
List
>>print c
[1,2,3,4]
String output, this is good for concatenating strings with variable names with numbers. Use this for plot titles and such rather than using the '+' indicator
print('print the numbers in this string here: {0}, here {1}, and here {2}.'.format(8,7,6))
As opposed to:
print 'print the numbers in this string here: ' +str(8)+', here '+ star(7)+', and here '+ str(s)+'.'
Subscribe to:
Posts (Atom)