Python
https://www.python.org/
ABAQUS through 6.14 appears to use Python 2.7.x
reserved words
https://docs.python.org/2/reference/lexical_analysis.html
and
del
from
not
while
as
elif
global
or
with
assert
else
if
pass
yield
break
except
import
print
class
exec
in
raise
continue
finally
is
return
def
for
lambda
try
python identifiers: variables, functions, modules, classes
class identifiers start in uppercase
indents are used as code blocks
if - elif is an if-elseif block
comments use #
#this is a comment
built in functions
https://docs.python.org/2/library/functions.html
Basic examples python 2.7.x
#error in
#https://www.amazon.com/Python-Beginners-Guide-Programming-Code-ebook/dp/B01MYO0CMV/ref=sr_1_1
#text string requires 'text'
print('Hello, World!')
#error in
#https://www.amazon.com/Python-Beginners-Programming-beginners-programming-ebook/dp/B01N3N6768/ref=sr_1_2
#input does not work, needed raw_input
#variable name is different than Name; uppercase and lowercase are different variables
name = raw_input('what is yourname?')
print ('Hello ' + name + '!')
#error in
#https://www.amazon.com/Python-Beginners-Guide-Programming-Code-ebook/dp/B01MYO0CMV/ref=sr_1_1
#text string requires 'text'
print('Hello, World!')
#error in
#examples below from this book, but corrected to work properly
#https://www.amazon.com/Python-Beginners-Programming-beginners-programming-ebook/dp/B01N3N6768/ref=sr_1_2
#input does not work, needed raw_input
#variable name is different than Name; uppercase and lowercase are different variables
#comment out these lines, but they do work
#name = raw_input('what is yourname?')
#print ('Hello ' + name + '!')
#this example doesn't work
#print(name[0]Upper()+[1:]Lower())
print (0.6/0.2)
# to slashes represent floor division; see the following for more details
#http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html
print (0.6//0.2)
a = round (3.14159, 2)
print a
a = round (3.14159, 4)
print a
stringa = str(a)
#the variable name below will not work
#string-a = str(a)
print ('pi to four digits: ' + stringa)
#mutable means variable can change values
#immutable means that the variable cannot change values
#strings
#\n newline
#\t tab
#\\ backslash
#\' single quote
#\" double quote
#index 0 on left, -1 on right side
#empty_tupl is not defined
#print(empty_tupl)
#these beginning python books are hoorendously written
A = [66.25, 333, 333, 1, 1234.5]
print A.count(333)
print A.count(66.25)
print A.count('x')
#inserts -1 into list after element 2
A.insert(2,-1)
#appends antother 333 at the end of the list
A.append(333)
print A
#removes the first 333
A.remove(333)
print A
A.reverse()
print A
A.sort()
print A
A.pop()
print A