Program 1 : Write a python script
to take input for 2 no.s and an
operator.Calculate and print the result.
Program 2 : Write a for generating a
random number between 1 and 6.
Program 3 : Write a python program
to implement a stack using a data
structures.
Program 4 : Write a python script to
take input for 2 no.s . Calculate and
print their sum,product,and difference.
Program 5 : Write a python program
to maintain book details like book
code,book title and price using stack
data structures.
Program 6 : Write a python program
to maintain employees details like
employee no ., name and salary using
queues data structures.
Program 7 : Write a python program to
read a file named "article.txt",count and
print total alphabets in the file.
Program 8 : Write a function to insert a
record in table using python and MYSQL
interface.
*iss waali coding me password ke aage data
base bhi aayega
# Program 8
import mysql.connector
def insert_record(emp_id, emp_name, emp_salary):
try:
conn = mysql.connector.connect(host="localhost", user="root",
password="password", database="testdb")
cursor = conn.cursor()
query = "INSERT INTO employees (id, name, salary) VALUES (%s,
%s, %s)"
values = (emp_id, emp_name, emp_salary)
cursor.execute(query, values)
conn.commit()
print("Record inserted successfully")
except mysql.connector.Error as err:
print("Error:", err)
finally:
if conn.is_connected():
cursor.close()
conn.close()
Program 9 : Write a function to display
all the records stored in a table using
python and MYSQL interface.
*iss waali coding me bhi password ke aage database bhi aayega
# Program 9
import mysql.connector
def display_records():
try:
conn = mysql.connector.connect(host="localhost", user="root",
password="password", database="testdb")
cursor = conn.cursor()
query = "SELECT * FROM employees"
cursor.execute(query)
records = cursor.fetchall()
for record in records:
print(record)
except mysql.connector.Error as err:
print("Error:", err)
finally:
if conn.is_connected():
cursor.close()
conn.close()
Program 10 : Write a python program
to enter the no. of terms and print the
Fibonacci series.
Program 11: Write a python program
that calculates and prints the number of
seconds in a year.
Program 12: Write a program that
creates a list of all the integers less
than 100 that are multiples of 3 or 5.
Program 13: Write a program that
prints a table on two columns - table that
helps converting miles into kilometres.
Program 14: Write a python program
that accepts two integers from the user
and prints a message saying if the first
number is divisible by second number or if
it is not.
Program 15: Write a python program to
display all the records in a file along
with line/record number.