0% 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.

Uploaded by

Ruchika
Copyright
© All Rights Reserved
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% 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.

Uploaded by

Ruchika
Copyright
© All Rights Reserved
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

Python Codes

nums = [1, 2, 3]
[Link](4)
print(nums)

nums = [1, 2, 3]
print(nums + [4, 5, 6])
print(nums * 3)
myfile = open("[Link]")

file = open("[Link]", "r")


cont = [Link]()
print(cont)
[Link]()
append

list
Open text

read file

You might also like