yw.193.cnc爆乳尤物未满_《和上司出差被强7天吉泽》_大陆农村妇女老bbwbbw https://www.大陆农村妇女老bbwbbw.org/blog/tag/tutorial/ Teach, learn and make with 棚拍人体 Pi Sun, 19 Sep 2021 15:46:26 +0000 en-GB hourly 1 https://wordpress.org/?v=6.9.4 https://www.大陆农村妇女老bbwbbw.org/app/uploads/2020/06/cropped-raspberrry_pi_logo-100x100.png https://www.大陆农村妇女老bbwbbw.org/blog/tag/tutorial/ 32 32 https://www.大陆农村妇女老bbwbbw.org/blog/how-to-build-databases-using-python-and-text-files-hello-world-9/ https://www.大陆农村妇女老bbwbbw.org/blog/how-to-build-databases-using-python-and-text-files-hello-world-9/#comments Tue, 09 Jul 2019 12:31:32 +0000 https://www.大陆农村妇女老bbwbbw.org/?p=52439

In Hello World issue 9, 棚拍人体 Pi’s own Mac Bowley shares a lesson that introduces students to databases using Python and text files. In this lesson, students create a library app for their books. This will store information about their book collection and allow them to display, manipulate, and search their collection. You will show students…

The post How to build databases using Python and text files | Hello World #9 appeared first on yw.193.cnc爆乳尤物未满.

]]>
In Hello World issue 9, 棚拍人体 Pi’s own Mac Bowley shares a lesson that introduces students to databases using Python and text files.

In this lesson, students create a library app for their books. This will store information about their book collection and allow them to display, manipulate, and search their collection. You will show students how to use text files in their programs that act as a database.

The project will give your students practical examples of database terminology and hands-on 涩爱av working with persistent data. It gives opportunities for students to define and gain concrete 涩爱av with key database concepts using a language they are familiar with. The script that accompanies this activity can be adapted to suit your students’ 涩爱av and competency.

This ready-to-go software project can be used alongside approaches such as PRIMM or pair programming, or as a worked example to engage your students in programming with persistent data.

What makes a database?

Start by asking the students why we need databases and what they are: do they ever feel unorganised? Life can get complicated, and there is so much to keep track of, the raw data required can be overwhelming. How can we use 棚拍人体 to solve this problem? If only there was a way of organising and accessing data that would let us get it out of our head. Databases are a way of organising the data we care about, so that we can easily access it and use it to make our lives easier.

Then explain that in this lesson the students will create a database, using Python and a text file. The example I show students is a personal library app that keeps track of which books I own and where I keep them. I have also run this lesson and allowed the students pick their own items to keep track of — it just involves a little more planning time at the end. Split the class up into pairs; have each of them discuss and select five pieces of data about a book (or their own item) they would like to track in a database. They should also consider which type of data each of them is. Give them five minutes to discuss and select some data to track.

Databases are organised collections of data, and this allows them to be displayed, maintained, and searched easily. Our database will have one table — effectively just like a spreadsheet table. The headings on each of the columns are the fields: the individual pieces of data we want to store about the books in our collection. The information about a single book are called its attributes and are stored together in one record, which would be a single row in our database table. To make it easier to search and sort our database, we should also select a primary key: one field that will be unique for each book. Sometimes one of the fields we are already storing works for this purpose; if not, then the database will create an ID number that it uses to uniquely identify each record.

Create a library application

Pull the class back together and ask a few groups about the data they selected to track. Make sure they have chosen appropriate data types. Ask some if they can find any of the fields that would be a primary key; the answer will most likely be no. The ISBN could work, but for our simple application, having to type in a 10- or 13-digit number just to use for an ID would be overkill. In our database, we are going to generate our own IDs.

The requirements for our database are that it can do the following things: save data to a file, read data from that file, create new books, display our full database, allow the user to enter a search term, and display a list of relevant results based on that term. We can decompose the problem into the following steps:

  • Set up our structures
  • Create a record
  • Save the data to the database file
  • Read from the database file
  • Display the database to the user
  • Allow the user to search the database
  • Display the results

Have the class log in and power up Python. If they are doing this locally, have them create a new folder to hold this project. We will be interacting with external files and so having them in the same folder avoids confusion with file locations and paths. They should then load up a new Python file. To start, download the starter file from the link provided. Each student should make a copy of this file. At first, I have them examine the code, and then get them to run it. Using concepts from PRIMM, I get them to print certain messages when a menu option is selected. This can be a great exemplar for making a menu in any application they are developing. This will be the skeleton of our database app: giving them a starter file can help ease some cognitive load from students.

Have them examine the variables and make guesses about what they are used for.

  • current_ID – a variable to count up as we create records, this will be our primary key
  • new_additions – a list to hold any new records we make while our code is running, before we save them to the file
  • filename – the name of the database file we will be using
  • fields – a list of our fields, so that our dictionaries can be aligned with our text file
  • data – a list that will hold all of the data from the database, so that we can search and display it without having to read the file every time

Create the first record

We are going to use dictionaries to store our records. They reference their elements using keys instead of indices, which fit our database fields nicely. We are going to generate our own IDs. Each of these must be unique, so a variable is needed that we can add to as we make our records. This is a user-focused application, so let’s make it so our user can input the data for the first book. The strings, in quotes, on the left of the colon, are the keys (the names of our fields) and the data on the right is the stored value, in our case whatever the user inputs in response to our appropriate prompts. We finish this part of by adding the record to the file, incrementing the current ID, and then displaying a useful feedback message to the user to say their record has been created successfully. Your students should now save their code and run it to make sure there aren’t any syntax errors.

You could make use of pair programming, with carefully selected pairs taking it in turns in the driver and navigator roles. You could also offer differing levels of scaffolding: providing some of the code and asking them to modify it based on given requirements.

How to use the code in your class

To complete the project, your students can add functionality to save their data to a CSV file, read from a database file, and allow users to search the database. The code for the whole project is available at helloworld.cc/database.

An example of the code

You may want to give your students the entire piece of code. They can investigate and modify it to their own purpose. You can also lead them through it, having them follow you as you demonstrate how an expert constructs a piece of software. I have done both to great effect. Let me know how your classes get on! Get in touch at [email protected]

Hello World issue 9

The brand-new issue of Hello World is out today, and available right now as a free PDF download from the Hello World website.

UK-based educators can also sign up to receive Hello World as printed magazine FOR FREE, direct to their door. And those outside the UK, educator or not, can subscribe to receive new digital issues of Hello World in their inbox on the day of release.

The post How to build databases using Python and text files | Hello World #9 appeared first on yw.193.cnc爆乳尤物未满.

]]>
https://www.大陆农村妇女老bbwbbw.org/blog/how-to-build-databases-using-python-and-text-files-hello-world-9/feed/ 6
https://www.大陆农村妇女老bbwbbw.org/blog/little-box-of-geek-from-geek-gurl-diaries/ https://www.大陆农村妇女老bbwbbw.org/blog/little-box-of-geek-from-geek-gurl-diaries/#comments Sun, 30 Dec 2012 12:16:11 +0000 http://www.大陆农村妇女老bbwbbw.org/?p=2953 The magnificent Miss Philbin from Geek Gurl Diaries has been having fun with a 棚拍人体 Pi, a thermal printer (the sort that till receipts are printed out on) and a big shiny button. She’s made a little Python fortune-telling box, which prints off geek pronouncements when the button’s pressed. Miss Philbin is the sort of…

The post Little Box of Geek from Geek Gurl Diaries appeared first on yw.193.cnc爆乳尤物未满.

]]>
The magnificent Miss Philbin from Geek Gurl Diaries has been having fun with a 棚拍人体 Pi, a thermal printer (the sort that till receipts are printed out on) and a big shiny button. She’s made a little Python fortune-telling box, which prints off geek pronouncements when the button’s pressed.

Miss Philbin is the sort of teacher you always wanted. She has some video which will take you step-by-step through setting up the printer, connecting it to the Pi’s GPIO, sorting out the serial port on your Pi, pulling thermal printer Python libraries off Github and getting the thing printing. That sort of thing might sound intimidating to beginners, but Carrie Anne is so good at explaining what’s going on that even those who have never picked up a Pi or used Linux before will be able to follow the tutorial. It’s a really good project if you’re somebody who wants to dive straight in to electronics engineering from a standing start. You’ll learn something, you’ll have made something fun, and you’ll never be afraid of wire strippers again.

There’s a full and very detailed blog post to accompany this video at Geek Gurl Diaries. You’ll find part two of the tutorial at Geek Gurl Diaries too (part two is, if anything, even more fun) along with more video. Get to it – and let us know if you give it a whirl!

Thanks Carrie Anne!

The post Little Box of Geek from Geek Gurl Diaries appeared first on yw.193.cnc爆乳尤物未满.

]]>
https://www.大陆农村妇女老bbwbbw.org/blog/little-box-of-geek-from-geek-gurl-diaries/feed/ 11