Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 7

: Write a python code to remove tuples from list of tuples if greater than n.

Given
a list of a
tuple, the task is to remove all the tuples from list, if it’s greater than n (say
100)

def check(s1, s2):

# the sorted strings are checked


if(sorted(s1) == sorted(s2)):
print("The strings are anagrams.")
else:
print("The strings aren't anagrams.")

# driver code
s1 = str(input())
s2 = str(input())
check(s1, s2)

1. Develop a Python Application to get the details of 5 users (Customer Id,Customer


Name, Last

3 Months of Units Consumed). Predict the no. of units that will be consumed in the
next month

as same, unpredict. (Hint: average of three months is less than or equal to last
month of unit

consumed then same else unpredict)

Bill id Customer id Name 3 months ofUnits Predict for nextMonth


[2:48 PM, 6/8/2021] M Ganga Devi: n=1
while n<=5:
print("Customer ",n)
customerID = int(input("Enter Customer ID "))
customerName = input("Enter Customer Name ")
lastMonth = int(input("Enter last Month units consumed "))
secondLastMonth = int(input("Enter Second Last Month units consumed "))
thirdLastMonth = int(input("Enter Third Last Month units consumed :"))
average = (lastMonth + secondLastMonth + thirdLastMonth)/3

print("------------------")

print("Bill Id : BCus_00",n)
print("Customer ID : ",customerID)
print("Customer Name : ",customerName)
print("Last Month units consumed : ",lastMonth)
print("Average of Last 3 Months Of Units : ",'%.2f' %average)
if average <= lastMonth:
print("Usage : Domestic")
else:
print("Usage : Commercialized")
n+=1
print("-------------------")
Design a GUI for the following scenario :
Imagine you as an internal Health Inspector in a Hospital. Now your duty is to
check the state of readiness of hospital in admitting the Corona Affected patients
by maintaining a Covid-19 database with the following column name in the Readiness
table,
Total Number of Doctors,
Total Number of Nurses,
Total Number of Health Care Assistants,
Number of Beds in Covid 19 ward,
Number of Beds in Covid 19 ICU ward,
Total Number of Oxygen Cylinders and
Total Number of Ventilator Units
Also, you must keep track of number of people who has taken their Covid-19
Vaccination from the month of January 2021 with the following column name in the
same database as a Vaccination table,
Name of the person,
Date of Vaccination,
Aadhar Number,
Date of Birth,
Age,
Dosage Count
Design your own form using python tkinter in getting the inputs for the above
mentioned tables and also display the records of ta
bles stored in the database.

from tkinter import *


from tkinter import ttk
import tkinter as tk
import sqlite3
import PIL
from PIL import ImageTk, Image

conn = sqlite3.connect('COVID19.db')

cursor = conn.cursor()

window=Tk()
window.title("COVID DETAILS")
window.geometry("440x550")
window.config(bg='white')

docs = Label(window,text="Total Number of Doctors",font=("bold",10), bg="#aa4557",


fg="#6edcdd").place(x=10,y=10)
e1 = Entry(window,width=20)
e1.place(x=270,y=10)

nurs = Label(window,text="Total Number of Nurses",font=("bold",10), bg="#aa4557",


fg="#6edcdd").place(x=10,y=50)
e2=Entry(window,width=20)
e2.place(x=270,y=50)

assis = Label(window,text="Total Number of Health Care


Assistants",font=("bold",10), bg="#aa4557", fg="#6edcdd").place(x=10,y=90)
e3=Entry(window,width=20)
e3.place(x=270,y=90)

bed = Label(window,text="Number of Beds in Covid 19 ward",font=("bold",10),


bg="#aa4557", fg="#6edcdd").place(x=10,y=130)
e4=Entry(window,width=20)
e4.place(x=270,y=130)

bedicu = Label(window,text="Number of Beds in Covid 19 ICU ward",font=("bold",10),


bg="#aa4557", fg="#6edcdd").place(x=10,y=170)
e5=Entry(window,width=20)
e5.place(x=270,y=170)

oxy = Label(window,text="Total Number of Oxygen Cylinders",font=("bold",10),


bg="#aa4557", fg="#6edcdd").place(x=10,y=210)
e6=Entry(window,width=20)
e6.place(x=270,y=210)

name = Label(window,text="Name of the person",font=("bold",10), bg="#aa4557",


fg="#6edcdd").place(x=10,y=250)
e7=Entry(window,width=20)
e7.place(x=270,y=250)

date = Label(window,text="Date of Vaccination",font=("bold",10), bg="#aa4557",


fg="#6edcdd").place(x=10,y=290)
e8=Entry(window,width=20)
e8.place(x=270,y=290)

aadh = Label(window,text="Aadhar Number",font=("bold",10), bg="#aa4557",


fg="#6edcdd").place(x=10,y=330)
e9=Entry(window,width=20)
e9.place(x=270,y=330)

dob = Label(window,text="Date of Birth",font=("bold",10), bg="#aa4557",


fg="#6edcdd").place(x=10,y=370)
e10=Entry(window,width=20)
e10.place(x=270,y=370)

age = Label(window,text="Age",font=("bold",10), bg="#aa4557",


fg="#6edcdd").place(x=10,y=410)
e11=Entry(window,width=20)
e11.place(x=270,y=410)

dose = Label(window,text="Dosage Count",font=("bold",10), bg="#aa4557",


fg="#6edcdd").place(x=10,y=450)
e12=Entry(window,width=20)
e12.place(x=270,y=450)

cursor.execute("""CREATE TABLE readiness(


e1 integer,
e2 integer,
e3 integer,
e4 integer,
e5 integer,
e6 integer
)""")

cursor.execute("""CREATE TABLE vaccination(


e7 text,
e8 integer,
e9 integer,
e10 integer,
e11 integer,
e12 integer
)""")

def update_data():
conn = sqlite3.connect('COVID19.db')
cursor = conn.cursor()
cursor.execute("INSERT INTO readiness VALUES(:e1, :e2, :e3, :e4, :e5, :e6)",
{
'e1': e1.get(),
'e2': e2.get(),
'e3': e4.get(),
'e4': e4.get(),
'e5': e5.get(),
'e6': e6.get()
})

cursor.execute("INSERT INTO vaccination VALUES(:e7, :e8, :e9, :e10, :e11,


:e12)",
{
'e7': e7.get(),
'e8': e8.get(),
'e9': e9.get(),
'e10': e10.get(),
'e11': e11.get(),
'e12': e12.get()
})
conn.commit()
conn.close()

def details():
newwindow = Tk()
newwindow.title("Details")
newwindow.geometry("900x300")

conn = sqlite3.connect('COVID19.db')
cursor = conn.cursor()

cursor.execute("SELECT *, oid FROM readiness")


details1 = cursor.fetchall()

cursor.execute("SELECT *, oid FROM vaccination")


details2 = cursor.fetchall()
#print(details)
print_details1 = ''
for detail1 in details1:
print_details1 +="\n" +"Readiness Table" + "\n" + "Total Number of Doctors
= " + str(detail1[0]) + " | " + "Total Number of Nurses = " + str(detail1[1]) +
" | " + "Total Number of Health Care Assistants = " + str(detail1[2]) + "\n" +
"Number of Beds in Covid 19 ward = " + str(detail1[3]) + " | " + "Number of Beds
in Covid 19 ICU ward = " + str(detail1[4]) + " | " + "Total Number of Oxygen
Cylinders = " + "Total Number of Ventilator Units = " + str(detail1[5]) + "\n"

detail1_label = Label(newwindow, text=print_details1)


detail1_label.place(x=1,y=25,anchor = W)

print_details2 = ''
for detail2 in details2:
print_details2 +="\n" + "Vaccination Table" + "\n" + "Name of the person =
" + str(detail2[0]) + " | " + "Date of Vaccination = " + str(detail2[1]) + " |
" + "Aadhar Number = " + str(detail2[2]) + "\n" + " | " + "Date of Birth = " +
str(detail2[3]) + " | " + "Age = " + str(detail2[4]) + " | " + "Dosage Count =
" + str(detail2[5]) + "\n"

detail2_label = Label(newwindow, text=print_details2)


detail2_label.place(x=1,y=100, anchor = W)

conn.commit()
conn.close()
newwindow.mainloop()

submitButton = Button(window, text="Submit", font=("bold",11), command=update_data,


bg="#6edcdd", fg="#ab4c5c").place(x=120,y=510)
viewButton = Button(window, text="View Records", font=("bold",11), command=details,
bg="#6edcdd", fg="#ab4c5c").place(x=200,y=510)
window.mainloop()

input 10,24,34,42,19

from functools import reduce


list = [10, 24, 34, 42, 19]
mul = reduce((lambda x, y: x * y), list)
sum = reduce((lambda x, y: x + y), list)
print(mul)
print(sum)

REVERSEHELLOMULTITHREADED

import threading, time


def print_time_361(threadName, delay, counter):# passing var and printing
while counter:
time.sleep(delay)
threadLock.acquire()
print ("%s: %s" % (threadName, counter))
counter -= 1
threadLock.release()
threadLock.release()
threadLock.release()
class myThread_361 (threading.Thread):
#initilizer
def init (self, name_361, counter,delay):
# initi thread ,name ,counter and delay.
threading.Thread. init (self)
self.name = name_361
self.counter = counter
self.delay = delay
def run_361(self):# this is method run
# Get lock to synchronize printing
#threadLock.acquire()
print_time_361(self.name, self.counter, self.delay)#calling print_time_3
# Free lock to release next thread
#threadLock.release()
threadLock = threading.RLock()#Re-entrant lock
threads_361 = []
# Create new threads
thread1_361 = myThread_361("Hello from Thread", 1,50)
thread1_361.run_361()#calling run_361 method frm thread _361 class
# Start new Threads
thread1_361.start()
# Add threads to thread list
threads_361.append(thread1_361)
# Wait for all threads to complete
for t in threads_361: #iterating over the list threads_361
t.join()
print ("Exiting Main Thread")

IMPORT THE THREAD MODULE

# Python program to illustrate the concept


# of threading
# importing the threading module
import threading

def print_cube(num):
"""
function to print cube of given num
"""
print("Cube: {}".format(num * num * num))

def print_square(num):
"""
function to print square of given num
"""
print("Square: {}".format(num * num))

if _name_ == "_main_":
# creating thread
t1 = threading.Thread(target=print_square, args=(10,))
t2 = threading.Thread(target=print_cube, args=(10,))

# starting thread 1
t1.start()
# starting thread 2
t2.start()

# wait until thread 1 is completely executed


t1.join()
# wait until thread 2 is completely executed
t2.join()

# both threads completely executed


print("Done!")

LILY HAS A CHOCOLATE

n = int(input())
s = list(map(int, input().split()))
d, m = map(int, input().split())

ans = 0
for i in range(n-m+1):
if (sum(s[i:i+m]) == d):
ans += 1

print(ans)
FUNCTION SQUARE

def square(n):
n = n**2
return n
def twice(f):
return square(f)
n = int(input("Enter a number: "))
quad = twice(square(n))
print(quad)

Write a automata code for Let Σ = {0, 1}. ??

from automata.fa.nfa import NFA

nfa = NFA(
states={'q0', 'q1', 'q2', 'q3'},
input_symbols={'a', 'b'},
transitions={
'q0': {'b': {'q3'}, 'a': {'q1'}},
'q1': {'a': {'q3'}, 'b': {'q2'}},
'q2': {'a': {'q1'}, 'b': {'q3'}},
'q3': {'a': {'q3'}, 'b': {'q3'}},
#'q4': {'0': 'q0', '1': 'q1'}
},
initial_state='q0',
final_states={'q2'}
)

n = str(input())
if nfa.accepts_input(n):
print("ACCEPTED")
else:
print("REJECTED")

You might also like