Skip to document
This is a Premium Document. Some documents on Studocu are Premium. Upgrade to Premium to unlock it.

Python slips 5th semester bba(ca)

its python slips that u need to submit in exams for marks
Course

Computer Engineering (410253B)

10 Documents
Students shared 10 documents in this course
Academic year: 2021/2022
Uploaded by:
0followers
1Uploads
3upvotes

Comments

Please sign in or register to post comments.

Preview text

Python-Slip

A- Write a Python program to accept n numbers in list and remove duplicates from a list.

First- Solution

marks =[]

n=int(input('Enter number of

elements : ')) for i in range(n):

value=int(input())

marks(value)

print(marks)

new_marks

=[] for x in

marks:

if x not in new_marks:

new_marks(x)

print(new_marks)

Enter number of elements : 5 1 2 3 5 2 [1, 2, 3, 5, 2] [1, 2, 3, 5]

B) Write Python GUI program to take accept your

birthdate and output your age when a button is

pressed.

import all functions from the

tkinter from tkinter import *

import messagebox class from

tkinter from tkinter import messagebox

Function for clearing thecontents of all text entry

boxes def clearAll() :

deleting the content from the

entry box dayField(0, END) monthField(0, END) yearField(0, END) givenDayField(0, END) givenMonthField(0, END) givenYearField(0, END) rsltDayField(0, END) rsltMonthField(0, END) rsltYearField(0, END)

function for checking

error def checkError() :

if any of the entry field is emptythen show an error message and

clear # all the entries if (dayField() == "" or monthField() == "" or yearField() == "" or givenDayField() == "" or givenMonthField() == "" or givenYearField() == "") :

show the error message

messagebox("Input Error")

clearAll function

calling clearAll()

return -

function to calculate

Age def calculateAge() :

check for error

calculated_month = given_month - birth_month; calculated_year = given_year - birth_year;

calculated day, month, year write backto the respective entry boxesinsert method inserting

the # value in the text entry box.

rsltDayField(10, str(calculated_day)) rsltMonthField(10, str(calculated_month)) rsltYearField(10, str(calculated_year))

Driver Code

if name == " main " :

Create a GUI

window gui = Tk()

Set the background colour of GUI window

gui(background = "light green")

set the name of tkinter GUI

window gui("Age Calculator")

Set the configuration of GUI

window gui("525x260")

Create a Date Of Birth : label

dob = Label(gui, text = "Date Of Birth", bg = "blue")

Create a Given Date : label

givenDate = Label(gui, text = "Given Date", bg = "blue")

Create a Day : label

day = Label(gui, text = "Day", bg = "light green")

Create a Month : label

month = Label(gui, text = "Month", bg = "light green")

Create a Year : label

year = Label(gui, text = "Year", bg = "light green")

Create a Given Day : label

givenDay = Label(gui, text = "Given Day", bg = "light green")

structure. dob(row = 0, column = 1)

day(row = 1, column = 0) dayField(row = 1, column = 1)

month(row = 2, column = 0) monthField(row = 2, column = 1)

year(row = 3, column = 0) yearField(row = 3, column = 1)

givenDate(row = 0, column = 4)

givenDay(row = 1, column = 3) givenDayField(row = 1, column = 4)

givenMonth(row = 2, column = 3) givenMonthField(row = 2, column = 4)

givenYear(row = 3, column = 3) givenYearField(row = 3, column = 4)

resultantAge(row = 4, column = 2)

rsltYear(row = 5, column = 2) rsltYearField(row = 6, column = 2)

rsltMonth(row = 7, column = 2) rsltMonthField(row = 8, column = 2)

rsltDay(row = 9, column = 2) rsltDayField(row = 10, column = 2)

clearAllEntry(row = 12,

column = 2) # Start the GUI gui()

ele+=

print('No. of Upper case characters : ',up)

print('No. of Lower case characters : ',low)

print('other special

symbols',ele)print(count1) print("The

number of uppercase characters is:")

print(count2)

enter a string : Abcdefg No. of Upper case characters : 1 No. of Lower case characters : 6 other special symbols 0

B) Write Python GUI program to create a digital clock with Tkinter to display the time.

import time

from tkinter import *

canvas = Tk()

canvas("Digital

Clock")

canvas("350x200")

canvas(1,1)

label = Label(canvas, font=("Courier", 30, 'bold'), bg="blue", fg="white", bd =30)

label(row =0,

column=1) def

digitalclock():

text_input = time("%H:%M: %S") label(text=text_input) label(200, digitalclock)

digitalclock()

canvas()

Output

Pythone-Slip 3

A-Write a Python program to check if a given key already exists in a dictionary. If key exists replace with another key/value pair.

Dict={}

n=int(input('enter number of

keys :')) for x in range(0,n):

key=input('enter the

key :') if key in Dict:

print('the given key exists!')

for key in

Dict():

print(key,end='

')

print('\n ^ use differnt keys from above

list') key=input('enter the key :')

value=input('enter the value :')

Dict[key]=value

print(Dict)

print("sub

marks :",self)

print("sub

marks :",self)

print("sub3 marks

:",self)

p1=Test(1,"amar",19,'male',82,89,76)

p2=Test(2,'priya',20,'female',94,91,84)

p1_marks()

p2_marks()

abc's marks: 247 sub marks : 82 sub2 marks : 89 sub3 marks : 76 pqr's marks: 269 sub1 marks : 94 sub2 marks : 91 sub marks : 84

Pythone-Slip 4

A)Write Python GUI program to create background with changing colors

from tkinter import Button, Entry, Label, Tk

def changecolor():

newvalue = value()

gui(background = newvalue)

B) Define a class Employee having members id, name, department, salary. Create a subclass called manager with member bonus. Define methods accept and display in both the classes. Create n objects of the manager class and display the details of the manager having the maximum total salary (salary+bonus).

class Employee:

def init (self, id, name, department, salary):

self=id

self=name

self=department

Was this document helpful?
This is a Premium Document. Some documents on Studocu are Premium. Upgrade to Premium to unlock it.

Python slips 5th semester bba(ca)

Course: Computer Engineering (410253B)

10 Documents
Students shared 10 documents in this course
Was this document helpful?

This is a preview

Do you want full access? Go Premium and unlock all 143 pages
  • Access to all documents

  • Get Unlimited Downloads

  • Improve your grades

Upload

Share your documents to unlock

Already Premium?
Python-Slip1
A- Write a Python program to accept n
numbers in list and remove duplicates from a
list.
First- Solution
marks =[]
n=int(input('Enter number of
elements : ')) for i in range(n):
value=int(input())
marks.append(value)
print(marks)
new_marks
=[] for x in
marks:
if x not in new_marks:
new_marks.append(x)
print(new_marks)
Enter number of
elements : 5 1
2
3
5
2
[1, 2, 3, 5, 2]
[1, 2, 3, 5]
B) Write Python GUI program to take accept your
birthdate and output your age when a button is
pressed.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.