Python Resources

Updated on Aug 4 2024

Python Resources

Deborah R. Fowler



I/O

Posted on Aug 29  2018
Updated on Jan 20  2020
Updated on Apr 10 2024 added script for manipulating turtle quilt file


NOTE: "In Python 2, raw_input() returns a string, and input() tries to run the input as a Python expression. Since getting a string was almost always what you wanted, Python 3 does that with input()"

input is returning a string. You can use float() or int() to get a decimal or whole number.
For example:
x = int( input("Showing number values - enter an integer "))


How many of you found having to edit your fd commands tedious? So tedious tasks are great opportunities to write scripts.

The script below touches on the concepts taught in lecture today (file I/O, split, slice). During office hours while helping someone, there were many lines of code with t.fd so it prompted me to write a script.

You may want to use this if you are in the process of changing your patterns. Since .py files are also ascii readable I open a student file I have called test.py (the setpos commands were done, however there were a large number of t.fd). A new file testResult.py is created by parsing the read file line by line and for lines with fd, bk or circle the script will add the " * scale" expression (so no hand editing). (Click on the image to download the script and example file)