See it to believe it:plz explain I/O


#1

please explain what is i/o , does it use file saved on computer , what is output.txt here?
is it an empty txt file saved on computer?


#2

input/output, you don't know what input and output are?

yes, although with certain libraries you could even write/read to files on a different computer

in the exercise the file is stored in the codecademy server, but if you would run this python code on your computer the file would be on a computer

files which are empty can be saved, yes.


#3

say i open notepad on my pc and save an empty file, name it (check.txt)
then i open my python idle, and write :slight_smile:
my_file=open("check.txt","w")
my_file.write("i want to understand I/O")
my_file.close()

will this code work?
will this write :i want to understand I/O :to my empty file saved in computer?
if not what's wrong with it?


#4

well, go and try.

you don't have to create the empty file first with notepad, using w will (over)write to file, if the file doesn't exist, python will create it

for appending to file we have r+ (then the file must exist)

also, there is a catch. The file will created in the current directory, see what this you can run:

import os
print os.getcwd()

(get current working directory)


#5

last one :say i have a file on my pc can i read that file on my console using I/O process?


#6

this depends on the file type, python supports certain file types, other file types can be opened using additional libraries. (you can google which file types this are, and if python supports opening the file type you want to open)


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.