Friday, September 21, 2018

Python moves in a mysterious way.

Consider (or run) the following program:

family = ["Paul", "Nick", "Niall", "Peter", "Michael", "Liz", "Beth"]
print (family)
print (sorted (family), "is defined as the list sorted")
print (max (family), "is defined as max of the list")
print (min (family), "is defined as min of the list")
#one way to make a list
for family in ["Paul", "Nick", "Niall", "Peter", "Michael", "Liz", "Beth"]:
print (family, "is a family member")
#add rafa and theo
family = ["Paul", "Nick", "Niall", "Peter", "Michael", "Liz", "Beth"]
family=family+["Theo"]
family=family+["Rafa"]
print (family)
print (max (family), "is defined as the new max of the list")
#to be continued

Peter was the max of the family until Theo and Rafa came along!

I am more interested in manipulating strings than numbers. One of the exercises is to write a program to solve quadratic equations. That would be like writing a program to do crosswords or soduko so you have no fun!.




Amazon Author Page

No comments: