[Tutorial]: Development of an institutions data collection back-end with python 3(Part 3)

in #utopian-io6 years ago

images.png
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.

  • Create the lecturer class for our program

  • Learn to update the text document we've created

For my previous posts in the python tutorial series
-Click Here* Creating a simple calculator using python 3.8(cpython)

Creating an encryption key(Cryptography)
- Part 1
- Part 2
- Part 3
- Part 4

Curriculum for this series
Part 1 of this series
Part 2 of this series

Tutorial
In this tutorial will be creating our lecturer class and defining each function within it. Since our database can run as a back-end for the institutions python run website new functions should be able to be created at anytime. The programs should be able to be modified easily.

Our lecturer class will be accepting three arguments which are name, gender and department. While writing this you could choose to add any valuable piece of core information that is part of the foundation of the class. The code for defining our lecturer class should look like this:

#The lecturer class should contain only core pieces of information. A function can be written to add any further details at any point. 
class Lecturer:
  def __init__(self,name,gender,department):  
    self.name = name
    self.gender = gender
    self.department = department   
    self.salary = 40000
    self.staff_data = open(self.name, "w+")
    data = [self.gender, self.department]
    for dat in data:
      self.student_data.write(dat)
    self.student_data.close()
 #We also define a function to manage how much a specific staff will receive as a monthly salary 
  def compiled_salary(self): 
    allowance = float(input("What is the compiled allowance"))
    salary = self.salary + allowance
    return salary
#To make salaries easier to be paid we also define staff levels which determine what the staff earns  
  def staff_upgrade(self,level):
    if level == 1:
      self.salary = 50000
    elif level == 2:
      self.salary == 60000
    elif level == 3:
      self.salary == 80000
    else:
      print("Invalid Input")

Note : From our program, data is not updated to our text fileunless we manually update this text file.
self. staff_data creates the directory for the data we have to collect and every function that we run updates it.

Hence whenever you input new data for a lecturer or student use the self.student_data or self.staff_data to create this directory.
Example:

tunde = Lecturer("Tunde Bajare","Male","Math and Statistics")
tunde.staff_data

This creates the file and stores all the data we've collected within it.
In an organization to keep user data anonymous it is better use employee codes like 01695 rather than an obvious keyword such as tundeso that finding data has to be more specific.

As we have always done run your code to your console and try our each function to see that they are bug free. Your output should still look like this.
Screenshot_20180712-172825_1531412934367.png

You can find my proof of work done in github

Sort:  

Thank you for your contribution.
This moderation might not be considered due to the below:

  • Your tutorial needs to be more detailed.
  • The tutorial is too basic.

Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Hello! I find your post valuable for the wafrica community! Thanks for the great post! We encourage and support quality contents and projects from the West African region.
Do you have a suggestion, concern or want to appear as a guest author on WAfrica, join our discord server and discuss with a member of our curation team.
Don't forget to join us every Sunday by 20:30GMT for our Sunday WAFRO party on our discord channel. Thank you.

Congratulations @yalzeee! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the total payout received

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Do not miss the last post from @steemitboard:
SteemitBoard World Cup Contest - The results, the winners and the prizes

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @yalzeee! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:
SteemitBoard World Cup Contest - The results, the winners and the prizes

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.32
TRX 0.11
JST 0.034
BTC 66785.29
ETH 3229.75
USDT 1.00
SBD 4.30