fork download
  1.  
  2. # Display the number of students who have secured 'A' grade:
  3.  
  4. sql="SELECT COUNT(*) FROM STUDENTS WHERE GRADE='A'"
  5. cursor.execute(sql)
  6. count = cursor.fetchone()[0]
  7. print("The number of students with 'A' grade is {count}")
  8.  
  9. # Add a new column called Rank in the table:
  10.  
  11. sql ='ALTER TABLE STUDENT ADD Rank CHAR(3)'
  12. cursor.execute(sql)
  13. mycon.commit()
  14. print('Field Added')
  15.  
  16. mycon.close()
Success #stdin #stdout 0.03s 25752KB
stdin
Standard input is empty
stdout
# Display the number of students who have secured 'A' grade:

sql="SELECT COUNT(*) FROM STUDENTS WHERE GRADE='A'"
 cursor.execute(sql)
 count = cursor.fetchone()[0]
 print("The number of students with 'A' grade is {count}")

 # Add a new column called Rank in the table:

 sql ='ALTER TABLE STUDENT ADD Rank CHAR(3)'
 cursor.execute(sql)
 mycon.commit()
 print('Field Added')
 
 mycon.close()