[Tutorial]: Development of an institutions data collection backend using python 3.6(Part 1)
image source
Repository: Python, Open Source Repository
Software: For software download python 3.0 compatible with your OS here
Difficulty : Basic
What you will learn:
In this tutorial you will learn how to
- Develop a Data Management system backend from scratch.
- Use the
datetime
module from python's standard library. - Create a program using object- oriented programming.
- How to gather data using
class
programming
For my previous posts in the python tutorial series
-Click Here* Creating a simple calculator using python 3.8(cpython)
Previous Curriculum(Creating an encryption key)
- Part 1 of this series
- Part 2 of this series
- Part 3 of this series
- Part 4 of this series
This previous post covers common bugs encountered when trying to write this code and how to fix them. It shows how to write this basic code from scratch.
Tutorial
All institutional websites that deal with data gathering and storage have backends and when you want to develop a website using Django, you have to develop the back-end with python. In this tutorial I will be giving a detailed description of how to develop from scratch using object oriented programming.
In this program we develop a back-end for a higher institution. Let's start with the data collection for the basic people found in such an institution. First the students.
We begin by printing a short description for our program and importing all python modules that well be using for this program. Import your datetime
module.
print("""Data collection and management system,
developed by yalzeee""")
#This program is built to manage data for a higher institution
#Start by importing functions we will need for this program
import datetime
#This command imports all functioms from the datetime library
#In this institution lets assume we have Students, Lecturers and Workers stored in this database
In object oriented programming we define class
's which specify the type of data we that variable contains. We proceed to creating a Student
Class.
class Student:
def __init__(self,name,gender, age, major):
self.name = name
self.gender = gender
if gender == "Male" or "male":
self.gen = "He"
elif gender == "Female" or "female":
self.gen = "She"
else:
self.gen = "It"
self.age = age
time = datetime.datetime.now()
self.tor = time
self.major = major
The student class takes data such as name
, age
,major
and tor
. The tor
function records when the data was input into the system by storing the
date time.date time. now()
result to a variable called time
.
Write and run your code and if written as explained you shouldn't have any errors in your console. Next thing we will do is to create a function within the class that gives a summary of data we've collected in a readable form. This makes any student complete data readable very easily.
We define a function called student_summary
def student_summary(self):
print("""%s is a %s student,%s entered this
institution at %s years old and was logged onto
our systems at %s. %s is here for a %s major" % (self.name, self.gender, self.gen, self.age, self"".tor, self.gen, self.major))
After you write this code run it by defining a variable for student data and then run the summary function on it.
Let's compile a student data under a variable called yalz
yalz = Student("Oyale Peter", "Male", "19", "Linguistics")
And then let's run the student_summary
on it.
Note: For class data functions are run in the following format class. function()
as opposed to the normal function(arguement
which would have been used in a normal python syntax.
print(yalz.student_summary())
In a normal back-end digits are used rather than names to identify data due to the large amount of data stored on the database.
In the next tutorial we will deal with creating other neccesary functions and how to limit this datas accessibility using decorators.
You can find my Proof of work done in
GITHUB
Hey @yalzeee
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Hello! I find your post valuable for the wafrica community! Thanks for the great post! @wafrica is now following you! ALWAYs follow @wafrica and use the wafrica tag!
Thank you for your contribution.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Thanks @portugalcoin
I will surely take note of that