Python Classroom notes 05/Sep/2024

Object oriented programming contd..

Movie ticketing system (rough design)

  • Classes:
    • Movie
    • Theatre
    • Screen
    • Screening
    • Seat
    • Booking
    • Payment
  • Refer Here for rough implementation Refer Here

Public and private in python

  • Python doesnot support public and private specifically but there are conventions
  • any member of method with a name starting from _ is generally considered private
  • If you want users not to access private give the name starting from __ (double underscore)

Application Types

  • Command line applications
  • Desktop/Thick client applications (We are not covering this)
  • Web applications (We are not covering this)
  • Web apis

Command Line Application

Hello cli

  • Write a program to say hello by taking only one argument from command line

Add cli

  • Write a program to add two numbers
python add.py 1 2
1 + 2 = 3

Some command line examples

ansible-playbook --inventory hosts test.yaml

# keyword arguments
add --number1 10  --number2 20
# positional arguments
add 10 20 

Commandline Password Manager

  • User should be passing digits
  • Version 1: Generate password
pmanager --length 16
  • Version 2: Give user some options for including special characters
pmanager --length 16 --include-special "@*_#"
  • Version 3: Give option for user to generate password and provide save and service name
pmanager generate --service gmail --length 12 --include-special "@&"
  • Version 4: Start saving passwords to a text file
pmanager generate --service gmail --length 12 --include-special "@&"
pmanager retrieve --service gmail
  • Version 5: Save passwords to an encrypted file
pmanager generate --service gmail --length 12 --include-special "@&" --secret "india123"
pmanager retrieve --service gmail --secret "india123"

Exercise

  • Try going through the following
    • Argument Parser
    • Read, Write, append files in python

Markdown format

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%