- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Python Operators / of python logical operators Real Time examples
from beautifultable import BeautifulTable table = BeautifulTable() table.column_headers = ["Movie Name", "Movie Language","Movie Length"] import MySQLdb 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 movie_name,movie_language,movie_length FROM bulkratings_info.tutorialstution_movies_list;") movies = tutorialCursor.fetchall() connection.close() movie_language = 'Hindi' movie_length = 150 for movie in movies: try: length = int(movie[2]) # print(movie) #Logical And Operator if movie[1]==movie_language or length > movie_length: table.append_row([movie[0], movie[1], movie[2]]) #Logical OR Operator # if movie[1]==movie_language or length < movie_length: # table.append_row([movie[0], movie[1], movie[2]]) #Logical NOT Operator # if not movie[1]==movie_language: # table.append_row([movie[0], movie[1], movie[2]]) except: pass print(table)