Write a Code to update Data in MYSQL from Python.
Class 12th CBSE CS Write a Code to update Data in MYSQL from Python. Solution: – import mysql.connector as cn s = cn.connect( host = “localhost”, user = “root”, passwd = “root”, database = “bank”, auth_plugin=”mysql_native_password”) mycursor = s.cursor() sql = “UPDATE customers SET address = ‘Surat’ WHERE address = ‘Vesu'” mycursor.execute(sql) s.commit() print(mycursor.rowcount, “record(s) […]
Write a Code to Delete and Update Data in MYSQL from Python.Â
Class 12th CBSE CS Write a Code to Delete Data in MYSQL from Python. Solution: – import mysql.connector as cn s = cn.connect( host = “localhost”, user = “root”, passwd = “root”, database = “bank”, auth_plugin=”mysql_native_password”) mycursor = s.cursor() sql = “DELETE FROM bank WHERE address = ‘Vesu'” mycursor.execute(sql) s.commit() print(mycursor.rowcount, “record(s) deleted”) Fun & […]
Write a Code to Insert Data from Python to MYSQL.
Class 12th CBSE CS Write a Code to Insert Data from Python to MYSQL. Solution: –Â import mysql.connector as cn s = cn.connect( host = “localhost”, user = “root”, passwd = “root”, database = “bank”, auth_plugin=”mysql_native_password”) mycursor = s.cursor() sql = “INSERT INTO bank (name, address) VALUES (%s, %s)” val = (“Hardik”, “Althan”) mycursor.execute(sql, val) […]
Write a Code to Connect Python with MYSQL.Â
Class 12th CBSE CS Write a Code to Connect Python with MYSQL. Solution: – import mysql.connector as cn s = cn.connect( host = “localhost”, user = “root”, passwd = “root”, database = “bank”, auth_plugin=”mysql_native_password”) if s.is_connected(): print(“Connected Successfully”) else: print(“Connected Unsuccessfully”) Fun & Easy to follow Works on all devices Your own Pace Super Affordable […]
Write a python program to write student data in a binary file.
Class 12th CBSE CS Write a python program to write student data in a binary file. Solution: – import pickle s={ } file2 = open(‘student.dat’ , ‘wb’) R = int (input (“Enter roll number=“ )) N = input(“Enter name =“ ) M = float(input (“Enter marks =“ ) # add read data into dictionary S […]
Write a function SwapNumbers( ) to swap two numbers and display the numbers before swapping and after swapping.
Class 12th CBSE CS Write a function SwapNumbers( ) to swap two numbers and display the numbers before swapping and after swapping. Solution: –Â def SwapNumbers(a, b): print(“Before swapping: a =”, a, “, b =”, b) a, b = b, a # This is the Pythonic way to swap variables print(“After swapping: a =”, a, […]
Write a Program  to perform Stack Operation.
Class 12th CBSE CS Write a Program  to perform Stack Operation. Solution: – def push(): n = int(input(“Enter the number you want to add in Stack :- “)) stack.append(n) def pop(): if stack ==[]: print(“Stack Underflow”) else: print(stack.pop()) def peep(): if stack ==[]: print(“Stack Underflow”) else: print(stack[-1]) def display(): for i in range(len(stack)-1,-1,-1): print(stack[i]) stack=[] […]
Given the school result data, analyse the performance of the students on different parameters, e.g subject wise or class wise.
Class 12th CBSE IP Given the school result data, analyse the performance of the students on different parameters, e.g subject wise or class wise. Solution: –Â import matplotlib.pyplot as plt Subject=[‘Physics’,’Chemistry’, ‘Hind”, Biology’, ‘ComputerSc’] Percentage=[85,78,65,90,100] plt.bar(Subject, Percentage, align=’center’,color=’green’) plt.xlabel(‘SUBJECTS NAME’) plt.ylabel(‘PASS PERCENTAGE’) plt.title(‘Bar Graph For Result Analysis’) plt.show() Fun & Easy to follow Works on […]
Write a program to Importing and Exporting data between pandas and CSV file.
Class 12th CBSE IP Write a program to Importing and Exporting data between pandas and CSV file. Solution: –Â import pandas as pd df = pd.read_csv(“E:emp.csv”) print(df) l = [{‘Name’:’A’,’B’,’C’}, {‘Marks’:55,65,75}, {‘Grade’:’C’,’B’,’A’}] df1=pd.DataFrame(l) df1.to_csv(“f1.csv”) Fun & Easy to follow Works on all devices Your own Pace Super Affordable Popular Videos https://www.youtube.com/watch?v=9uOETcuFjbE UX for Teams Learn […]
Write a program to convert csv into a data frame and then display it.
Class 12th CBSE Write a program to convert csv into a data frame and then display it. Solution: –Â import pandas as pd df= pd.read_csv(‘MelaSales.csv’) print(df) Fun & Easy to follow Works on all devices Your own Pace Super Affordable Popular Videos https://www.youtube.com/watch?v=9uOETcuFjbE UX for Teams Learn the basics and a bit beyond to improve […]