This Python code defines a list called nums with values 1, 2, 3. It appends 4 to nums and prints the new list. It prints the sum of nums and a new list, and prints nums multiplied by 3. It then opens a text file, reads the contents and prints it, and closes the file.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
6 views2 pages
Python List Operations and File I/O
This Python code defines a list called nums with values 1, 2, 3. It appends 4 to nums and prints the new list. It prints the sum of nums and a new list, and prints nums multiplied by 3. It then opens a text file, reads the contents and prints it, and closes the file.