# File Input/Output > Tenth graders learn file input/output — reading data from files and writing data to them. Files let a program save information that lasts beyond a single… **Computer Science** | **Grade 10** *A free lesson plan from K12 Academics. Source page: https://lessonplans.k12academics.com/k12-lesson-g10-cs-file-io.html* Tenth graders learn file input/output — reading data from files and writing data to them. Files let a program save information that lasts beyond a single run. They check the ideas, then read and write a file. **Copy link** works with Canvas, Schoology, Moodle and any other LMS — paste it in as a resource or assignment. ## Everything you need before the bell rings ### Learning Objectives Students will be able to… - Read from a **file**. - Write to a **file**. - Make data **persist**. - Close files properly. How does a program save data so it’s still there next time? Project each one and have students answer about file I/O. ## 50 minutes, five moves Tap any phase to open the teacher moves and student actions. ### Hook — Where Did It Go? Your program saves a high score — but it’s gone when you restart. Why? #### 👩‍🏫 Teacher Moves - Pose the question. - Share ideas. - Set the goal. #### 🎒 Student Actions - Think. - Share. - Get ready. ### Use — File I/O Students learn. #### 👩‍🏫 Teacher Moves - Send students to File Input/Output. - Note files persist, variables do not. - Note close files. #### 🎒 Student Actions - Answer. - Note it. - Note it. ### Modify — Read & Write Students practice. #### 👩‍🏫 Teacher Moves - Open a file for reading. - Read its contents. - Open one for writing. #### 🎒 Student Actions - Open. - Read. - Write. ### Create — Create Students apply. #### 👩‍🏫 Teacher Moves - Write data to a file. - Read it back. - Use a ‘with’ block. #### 🎒 Student Actions - Write. - Read. - With. ### Reflect — Reflect Students close. #### 👩‍🏫 Teacher Moves - What does file I/O do? - How do you save data? - Complete the exit ticket. #### 🎒 Student Actions - Say it. - Say it. - Complete the exit ticket. ## Built to the standards you report on Aligned to the CSTA K-12 Computer Science Standards and the ISTE Standards for Students. Use file I/O in programs. Store and retrieve data. Test file-handling code. Manage data in programs. ## One lesson, every learner ### Multilingual Learners - Read/write diagram. - Frame: "a file keeps data ___." - Demo file I/O. ### Support & Access - Read a file only. - Use a sample file. - Use a template. ### Stretch & Extend - Read a CSV file. - Append to a file. - Handle a missing file. ### What to gather - 📽️Screen / board - 📄Sample files - 💻File Input/Output - 💻Python - 📓Notebooks - 🎫Exit-ticket slips ### Key terms - **file I/O**: reading and writing files - **read**: get data from a file - **write**: save data to a file - **persist**: data that lasts - **open**: access a file - **close**: finish with a file - **with block**: auto-closes a file - **path**: a file’s location ## Exit Ticket Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students. ### Reflect: file input/output. Have students write data to a file and read it back. A printable file-I/O sheet is in the CS library. ## Check your understanding **1. What does “file I/O” mean?** - data that lasts - a file’s location - finish with a file - reading and writing files *(correct)* “file I/O” means: reading and writing files **2. Which word means: “get data from a file”?** - close - write - read *(correct)* - open “read” means: get data from a file **3. What does “write” mean?** - get data from a file - save data to a file *(correct)* - reading and writing files - a file’s location “write” means: save data to a file **4. Which word means: “data that lasts”?** - path - file I/O - with block - persist *(correct)* “persist” means: data that lasts **5. What does “open” mean?** - a file’s location - finish with a file - access a file *(correct)* - get data from a file “open” means: access a file **6. Which word means: “finish with a file”?** - close *(correct)* - write - persist - read “close” means: finish with a file ## Printable worksheet --- Full lesson page: https://lessonplans.k12academics.com/k12-lesson-g10-cs-file-io.html All lessons: https://lessonplans.k12academics.com/