- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Python Operators / of Arithmetic Operator Real Time Example
import MySQLdb from beautifultable import BeautifulTable table = BeautifulTable() table.column_headers = ["Book Name", "Actual Price","Selling Rate", "lose Price"] try: connection = MySQLdb.connect(user='root',password='sairam143sairam',port=3306,host='localhost') except Exception as e: print(e) else: tutorialCursor = connection.cursor() tutorialCursor.execute("SELECT title,flipkartSellingPrice_amount FROM books.flipkart_books_feed_final;") Books = tutorialCursor.fetchall() connection.close() for Book in Books[:10]: try: profit_price = Book[1]*(10/100) BookName = Book[0] BookActualPrice = Book[1] afterAddingPer = BookActualPrice - profit_price table.append_row([BookName, BookActualPrice, afterAddingPer, profit_price]) except: pass print(table)