Close Menu
Soshace Digital Blog

    Subscribe to Updates

    Get The Latest News, Updates, And Amazing Offers

    What's Hot
    Interview

    An Interview with a Freelancer Who Actually Ended Up on the Island: “I Live and Code in a Paradise”

    LinkedIn

    Building LinkedIn Authority: Strategies for Effective Lead Generation

    SaaS & Tech

    Maximizing Impact: Strategies for SaaS & Technology Marketing

    Important Pages:
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Today's Picks:
    • Scaling Success: Monitoring Indexation of Programmatic SEO Content
    • Leveraging Influencers: Key Drivers in New Product Launches
    • How Privacy-First Marketing Will Transform the Industry Landscape
    • The Impact of Social Proof on Thought Leadership Marketing
    • Balancing Value-Driven Content and Promotional Messaging Strategies
    • Top Influencer Marketing Platforms to Explore in 2025
    • Emerging Trends in Marketing Automation and AI Tools for 2023
    • Strategies to Mitigate Duplicate Content in Programmatic SEO
    Wednesday, September 10
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Soshace Digital Blog
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Services
    • SaaS & Tech

      Maximizing Efficiency: How SaaS Lowers IT Infrastructure Costs

      August 27, 2025

      Navigating Tomorrow: Innovations Shaping the Future of SaaS

      August 27, 2025

      Maximizing Impact: Strategies for SaaS & Technology Marketing

      August 27, 2025
    • AI & Automation

      Enhancing Customer Feedback Analysis Through AI Innovations

      August 27, 2025

      Navigating the Impact of AI on SEO and Search Rankings

      August 27, 2025

      5 Automation Hacks Every Home Service Business Needs to Know

      May 3, 2025
    • Finance & Fintech

      Critical Missteps in Finance Marketing: What to Avoid

      August 27, 2025

      Analyzing Future Fintech Marketing Trends: Insights Ahead

      August 27, 2025

      Navigating the Complex Landscape of Finance and Fintech Marketing

      August 27, 2025
    • Legal & Compliance

      Exploring Thought Leadership’s Impact on Legal Marketing

      August 27, 2025

      Maximizing LinkedIn: Strategies for Legal and Compliance Marketing

      August 27, 2025

      Why Transparency Matters in Legal Advertising Practices

      August 27, 2025
    • Medical Marketing

      Enhancing Online Reputation Management in Hospitals: A Guide

      August 27, 2025

      Analyzing Emerging Trends in Health and Medical Marketing

      August 27, 2025

      Exploring Innovative Content Ideas for Wellness Blogs and Clinics

      August 27, 2025
    • E-commerce & Retail

      Strategic Seasonal Campaign Concepts for Online and Retail Markets

      August 27, 2025

      Emerging Trends in E-commerce and Retail Marketing Strategies

      August 27, 2025

      Maximizing Revenue: The Advantages of Affiliate Marketing for E-Commerce

      August 27, 2025
    • Influencer & Community

      Leveraging Influencers: Key Drivers in New Product Launches

      August 27, 2025

      Top Influencer Marketing Platforms to Explore in 2025

      August 27, 2025

      Key Strategies for Successful Influencer Partnership Negotiations

      August 27, 2025
    • Content & Leadership

      The Impact of Social Proof on Thought Leadership Marketing

      August 27, 2025

      Balancing Value-Driven Content and Promotional Messaging Strategies

      August 27, 2025

      Analyzing Storytelling’s Impact on Content Marketing Effectiveness

      August 27, 2025
    • SEO & Analytics

      Scaling Success: Monitoring Indexation of Programmatic SEO Content

      August 27, 2025

      Strategies to Mitigate Duplicate Content in Programmatic SEO

      August 27, 2025

      Effective Data Visualization Techniques for SEO Reporting

      August 27, 2025
    • Marketing Trends

      How Privacy-First Marketing Will Transform the Industry Landscape

      August 27, 2025

      Emerging Trends in Marketing Automation and AI Tools for 2023

      August 27, 2025

      Maximizing ROI: Key Trends in Paid Social Advertising

      August 27, 2025
    Soshace Digital Blog
    Blog / Programming / Think Like a Pythonista — Building a Book Sharing App
    Beginners

    Think Like a Pythonista — Building a Book Sharing App

    Bhavani RaviBy Bhavani RaviFebruary 6, 2020Updated:February 6, 2020No Comments9 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Think Like a Pythonista — Building a Book Sharing App
    Think Like a Pythonista
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link
    Think Like a Pythonista -- Building a Book Sharing App
    Think Like a Pythonista — Building a Book Sharing App

    Python is at its hot seat — thanks to the boom of machine learning and artificial intelligence and startups wanting to implement their proof of concept quickly using a single language for the whole stack — the need for Python developers had skyrocketed in recent years.

    As a result, a lot of people are moving towards learning Python. There is an insane amount of articles and tutorials online. I have been working with a lot of communities and taught Python to newbies who want to get into the industry. By working with people from a wide spectrum of college students to fresh graduates to people entering the industry after a break, the common pattern with all these tutorials is that they never get you beyond the syntactic side of python. While having these Python constructs at the back of your hand comes in handy while coding, that is not all it is to becoming a Pythonista.

    Who is a Pythonista

    A Pythonista is someone who uses Python programs to perform specific tasks. They know Python so well that when they look at the problem, thanks to Python’s English like constructs, they think through the solution completely in Python.

    The tasks can be as simple as

    1. Searching Google
    2. Sending an email
    3. Scraping a website
    4. Reading a file
    5. Drawing charts

    What is an Application?

    An application is a software program written for end-users (people who are not into tech). In this case, imagine you as a software developer, and you are writing this app for a person who is a book freak.

    There are different kinds of applications, mostly defined by the way in which the user interacts with the app.

    1. Command-line application
    2. Desktop application
    3. Mobile application
    4. Web application
    5. AR / VR application

    In this blog, we are going to learn Python by building a book sharing application. We are going to build it as a command-line application the ones you can fire up on your terminal.

    How to consume this blog?

    Things are going to get heated now, treat this blog as a workshop where the instructor guides you step by step through the process. Hence, you are expected to hands-on. Boot up your laptop, open the blog on one side and try the exercises, code blocks and the other side. If you are stuck or find an error in the middle, check stackoverflow.com and Google the error messages — it will help you find your way. Most importantly, give it time, you might not be able to build this app at your first read, keep at it. Try it tomorrow, reach out to people for help, look into other tutorials.  You will get there.

    What makes an Application?

    Whenever we talk about building an application, we broadly think about three things:

    1. Interaction
    2. Features
    3. Data
    4. Implementation

    Interactions

    1. On starting the app, users are provided with a menu to choose whether they want to list, add, edit or share a book
    2. User can choose “add” to add books that they have
    3. User can choose “list,” all books are listed
    4. On adding the books, they get stored
    5. When the user starts the app next time, the stored books should be preserved.
    6. User can “edit”/update the book details
    7. Once a book is added, user can “share” the book with their friends, for now, let’s just add a name under the label SharedWith

    Features

    1. List books
    2. Add books
    3. Update book
    4. Share

    Data

    Now, we take each item from the feature list and figure out what data we need to perform the operation on and how to design them. The idea of this section is to figure out.

    1. What to store?
    2. Where to store?
    3. How to store it?

    List books

    What to store

    The minimum detail you need to list books is Book Name and Author

    Where to store

    We have different storage options like files, database, cloud, etc., Let’s stick with files to keep things simple.

    Read More:  Top 20 Java String Interview Questions And Answers

    How to store it

    If you think about it, any file that lets us store data in a tabular format would come handy. That gives us two options CSV and Excel. CSV are text files with comma-separated values that look like this.

    Title, Author
    Atomic Habits, James Clear 
    Life is what you make it, Preethi Shenoy 
    Power of Habits, Charles Duhigg

    Add/Update Book

    For adding or updating a book we don’t need any details beyond Title or Author

    Share Book

    When it comes to sharing a book,

    1. User might be willing to share a book only if they have already read it
    2. User needs to store details of a person who they shared the book with

    So, for the book sharing app, we are storing Title, Author, IsRead, SharedWith

    Setup

    System Setup

    We need a few pre-requisites before we start building the app:

    1. Of course, a laptop
    2. Install Python 3.7
    3. python command working in your terminal
    4. Your favorite code editor, I use VSCode.

    Project Setup

    1. Create a folder say book-app
    2. Create a file with the name app.py
    3. Create a file books.csv this is where we store our booklist

    MindSet

    1. A lot of enthusiasm and curiosity
    2. A good chunk of time
    3. Good Wifi
    4. Maybe a shot of coffee

    Implementation

    Let’s split the features into smaller tasks and look at their Python implementation.

    Listing the menu – On running app.py using python app.py command we would show the user a bunch of options to choose from. We can do this using python print statements

    print("Menu ::")
    print("1. Add Book")
    print("2. Update Book")
    print("3. Share Book")
    print("4. List Book")

    Choosing an option – Next, we need to let the user choose an option 1,2 or 3. We can use python’sinput command to get input from the user. Also, we need to store this option somewhere so that we can perform it later. We can store it in a python variable.

    choice = int(input("Enter your option ::"))
    

    Now on knowing what the choice is, we need to call respective Python function.

    if choice == 1:
        add_book()
    
    elif choice == 2:
        update_book()
    
    elif choice == 3:
        share_book()
    
    elif choice == 4:
        list_books()

    For each function call we need to write the corresponding function definitions

    Add Book

    • For us to add a book we need to get its name and author from the user
    • Next, we need to add this book details to book.csv file for that we need to understand

    Functions should be defined before calling, make sure to add next chunks of code before the if statements

    def add_book():
        # 4.1
        book_name = input("Enter book name")
        author = input("Enter Author name")
    
        # 4.2
        import csv
        # Opens the file in writing mode
    
        with open('books.csv', mode='a') as f:
            writer = csv.DictWriter(f, fieldnames=[
                                    "BookName", "Author", 
                                    "Read", "SharedWith"])
            writer.writerow({"BookName": book_name,
                             "Author": author})

    Update Book

    • Get the name of the book to be updated from the user
    • Get the details that need to be updated, for now, let’s just keep it to marking the book as read or not read
    • Read the books from the file and find if the book already exists in the
    • If it does, update the detail
    def update_book():
        # 5.1
        book_name = input("Enter book name ::")
    
        # 5.2
        is_book_read = input("Book Read (Y/N)?")
    
        if is_book_read == "Y":
            is_book_read = True
    
        elif is_book_read == "N":
            is_book_read = False
    
        # 5.3
        import csv
        rows = []
    
        # Opens the file in reading and writing mode
        with open('books.csv', mode='r') as f:
            rows = list(csv.DictReader(f))
    
            # 5.4
            for row in rows:
                if row["BookName"] == book_name:
                    row["Read"] = is_book_read
                    break
    
        with open('books.csv', mode='w') as f:
            csv_writer = csv.DictWriter(
                f, fieldnames=["BookName", "Author", "Read", "SharedWith"])
            csv_writer.writerows(rows)
    
        print("Book Successfully Updated")
    

    Share Book – It is exactly the same as the update_book function, except you, update the field SharedWith your friend’s name. At this point, I challenge you to copy-paste edit_book and update the functionality

    Read More:  A Roundup Review of the Best Deep Learning Books

    List Books – We have also seen parts of what list books need to do in previous functions

    • Read the file and get all the books
    • Loop through the books and print them
    import csv
    
    def list_books():
        # Opens the file in reading and writing mode
        with open('books.csv', mode='r') as f:
            rows = csv.DictReader(f)
    
            for row in rows:
                print("n")
                print("Book Name :: " + row["BookName"])
                print("Author :: " + row["Author"])
                print("Read :: " + row["Read"])
                print("SharedWith :: " + row["SharedWith"])

    With that, we have completed implementing all our features. The final code looks at this.

    import csv
    
    def list_books():
        # Opens the file in reading and writing mode
        with open('books.csv', mode='r') as f:
            rows = csv.DictReader(f)
    
            for row in rows:
                print("n")
                print("Book Name :: " + row["BookName"])
                print("Author :: " + row["Author"])
                print("Read :: " + row["Read"])
                print("SharedWith :: " + row["SharedWith"])
    
    
    def update_book():
        # 5.1
        book_name = input("Enter book name ::")
    
        # 5.2
        is_book_read = input("Book Read (Y/N)?")
    
        if is_book_read == "Y":
            is_book_read = True
    
        elif is_book_read == "N":
            is_book_read = False
    
        # 5.3
        rows = []
    
        # Opens the file in reading and writing mode
        with open('books.csv', mode='r') as f:
            rows = list(csv.DictReader(f))
    
            # 5.4
            for row in rows:
                if row["BookName"] == book_name:
                    row["Read"] = is_book_read
                    break
    
        with open('books.csv', mode='w') as f:
            csv_writer = csv.DictWriter(
                f, fieldnames=["BookName", "Author", "Read", "SharedWith"])
            csv_writer.writerows(rows)
    
        print("Book Successfully Updated")
    
    
    def add_book():
        # 4.1
        book_name = input("Enter book name")
        author = input("Enter Author name")
    
        # 4.2
        import csv
        # Opens the file in writing mode
    
        with open('books.csv', mode='a') as f:
            writer = csv.DictWriter(f, fieldnames=[
                "BookName", "Author", "Read", "SharedWith"])
            writer.writerow({"BookName": book_name,
                             "Author": author})
    
        print("Book Successfully Added")
    
    
    print("Menu ::")
    print("1. Add Book")
    print("2. Update Book")
    print("3. Share Book")
    print("4. List Book")
    
    
    choice = int(input("Enter your option ::"))
    
    if choice == 1:
        add_book()
    
    elif choice == 2:
        update_book()
    
    elif choice == 3:
        share_book()
    
    elif choice == 4:
        list_books()
    

    Here are a few things you can try next:

    1. Maintain the record of BookStartDate and BookEndDate
    2. For each book, you can create a new file to create notes and store the name of the file under Notes in books.csv
    3. Come up with your own crazy feature, figure out the data, interactions, and deep dive into the code.

    If you have come this far into the blog, give yourself a pat on the back; if you have successfully implemented the code and could finish the exercises then you are already way ahead of most people trying to learn Python. Next up, you can use my How to build your 1st web application tutorial to build your first web app. If you found this tutorial helpful, give me a shoutout on Twitter.

    P.S. Project’s GitHub repo: https://github.com/bhavaniravi/book-app-python-tutorial

    python pythonista
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Bhavani Ravi

      Related Posts

      Mastering REST APIs: Essential Techniques for Programmers

      December 18, 2024

      Crafting Interactive User Interfaces Using JavaScript Techniques

      December 17, 2024

      Effective Strategies for Utilizing Frameworks in Web Development

      December 16, 2024
      Leave A Reply Cancel Reply

      You must be logged in to post a comment.

      Stay In Touch
      • Facebook
      • Twitter
      • Pinterest
      • Instagram
      • YouTube
      • Vimeo
      Don't Miss
      JavaScript October 25, 2018

      Top 3 Myths About Remote Web Developers

      Without a question you have heard many times about the Fortune 500 remote tech teams, which achieve from year to year incredible success in business, working remotely and hiring a freelance web developer or full-time remote programmers for the projects and product development.

      REST API Design Best Practices

      February 28, 2020

      Essential Steps for Beginners in Mobile App Development

      November 24, 2024

      Deploying Your NodeJS Code to a Server Every Time You Push with Github Actions

      June 29, 2020

      Categories

      • AI & Automation
      • Angular
      • ASP.NET
      • AWS
      • B2B Leads
      • Beginners
      • Blogs
      • Business Growth
      • Case Studies
      • Comics
      • Consultation
      • Content & Leadership
      • CSS
      • Development
      • Django
      • E-commerce & Retail
      • Entrepreneurs
      • Entrepreneurship
      • Events
      • Express.js
      • Facebook Ads
      • Finance & Fintech
      • Flask
      • Flutter
      • Franchising
      • Funnel Strategy
      • Git
      • GraphQL
      • Home Services Marketing
      • Influencer & Community
      • Interview
      • Java
      • Java Spring
      • JavaScript
      • Job
      • Laravel
      • Lead Generation
      • Legal & Compliance
      • LinkedIn
      • Machine Learning
      • Marketing Trends
      • Medical Marketing
      • MSP Lead Generation
      • MSP Marketing
      • NestJS
      • Next.js
      • Node.js
      • Node.js Lessons
      • Paid Advertising
      • PHP
      • Podcasts
      • POS Tutorial
      • Programming
      • Programming
      • Python
      • React
      • React Lessons
      • React Native
      • React Native Lessons
      • Recruitment
      • Remote Job
      • SaaS & Tech
      • SEO & Analytics
      • Soshace
      • Startups
      • Swarm Intelligence
      • Tips
      • Trends
      • Vue
      • Wiki
      • WordPress
      Top Posts

      Leveraging LinkedIn Recommendations for Effective Prospecting

      LinkedIn December 16, 2024

      Malesuada Proin Libero Nunc Consequat Interdum

      JavaScript January 28, 2020

      Flask Development Made Easy: A Comprehensive Guide to Test-Driven Development

      Flask January 4, 2024

      Attending Tech Conferences: Pros vs Cons & Plan of Action

      Events July 18, 2019

      Subscribe to Updates

      Get The Latest News, Updates, And Amazing Offers

      About Us
      About Us

      Soshace Digital delivers comprehensive web design and development solutions tailored to your business objectives. Your website will be meticulously designed and developed by our team of seasoned professionals, who combine creative expertise with technical excellence to transform your vision into a high-impact, user-centric digital experience that elevates your brand and drives measurable results.

      7901 4th St N, Suite 28690
      Saint Petersburg, FL 33702-4305
      Phone: 1(877)SOSHACE

      Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
      Our Picks
      Blogs

      Strategies for Cultivating a Robust Talent Pool

      Finance & Fintech

      Critical Missteps in Finance Marketing: What to Avoid

      LinkedIn

      Strategies to Enhance Your LinkedIn Profile for Lead Generation

      Most Popular

      Advanced Mapmaking: Using d3, d3-scale and d3-zoom With Changing Data to Create Sophisticated Maps

      JavaScript

      Upload Multiple Images to a Django Model without plugins

      Beginners

      Code Review

      Programming
      © 2025 Soshace Digital.
      • Home
      • About
      • Services
      • Contact Us
      • Privacy Policy
      • Terms & Conditions

      Type above and press Enter to search. Press Esc to cancel.