- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Python Operators / of Assignment Operator Real Time Examples
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_length FROM bulkratings_info.tutorialstution_movies_list;") movies = tutorialCursor.fetchall() connection.close() group_B = 100 #length of movie totalTimes = 0 for movie in movies: try: timeLength = int(movie[1]) #Increment Operator totalTimes = totalTimes - timeLength # print(movie) # #========================================================= # #Decrement Operator # totalTimes = totalTimes - timeLength # print(totalTimes) # # #========================================================= # #Multiplication Operator # totalTimes = totalTimes * timeLength # print(totalTimes) # # # #========================================================= # #Division Operator # totalTimes = totalTimes / timeLength # print(totalTimes) # # #========================================================= # #Modulus Operator # totalTimes = totalTimes % timeLength # print(totalTimes) # # #========================================================= # #Asterisk Operator # totalTimes = totalTimes % timeLength # print(totalTimes) # # #========================================================= # #Floor Operator # totalTimes = totalTimes // timeLength # print(totalTimes) except: pass print('Total time :- ',totalTimes,'min') print('Total time :- ',totalTimes/60,'Hours') print('Total time :- ',totalTimes/(60*24),'Days')