WEEK-1
2.Start a Python interpreter and use it as a Calculator.
program:
a=100
b=20
print(a+b)
print(a-b)
print(a*b)
print(a/b)
print(a%b)
print(a//b)
3.i) Write a program to calculate compound interest when principal, rate and
number of periods are given.
program:
principal = int(input("enter principal amount : "))
rate = float(input("enter rate of interest : "))
time = int(input("enter period : "))
Amount = principal * (pow((1 + rate / 100), time))
CI = Amount - principal
print("Compound interest is : ", CI)
output:
enter principal amount : 10000
enter rate of interest : 8.5
enter period : 5
Compound interest is : 5036.566901781247
ii) Given coordinates (x1, y1), (x2, y2) find the distance between two points
program:
import math
x1=int(input("enter x1 : "))
x2=int(input("enter x2 : "))
y1=int(input("enter y1 : "))
y2=int(input("enter y2 : "))
result =((x2-x1)**2+(y2-y1)**2)*(0.5)
print("distance between",(x1,x2),"and",(y1,y2),"is : ",result)
output:
enter x1 : 4
enter x2 : 8
enter y1 : 5
enter y2 : 1
distance between (4, 8) and (5, 1) is :16.0
4. Read name, address, email and phone number of a person through keyboard
and print the details.
program:
name = input("enter your name : ")
address = input("enter address : ")
email = input("enter email id : ")
mobile = input("enter mobile number : ")
print("\nPersonal Details \n")
print("Name: {}\nAddress: {}\nEmail: {}\nMobile: {}".format(name,address, email,
mobile))
output:
enter your name : Trishika
enter address : Sainikpuri, Secunderabad
enter email id : [email protected]
enter mobile number : 8777675747
Personal Details
Name: Trishika
Address: Sainikpuri, Secunderabad
Email:
[email protected]Mobile: 8777675747
Week-2
1.Print the below triangle using for loop.
5
44
333
2222
11111
Program:
rows = int(input("Enter number of rows: "))
for i in range(1 ,n+1):
for j in range(i):
print(n+1-i, end=” “)
print()
output:
Enter number of rows: 5
5
44
333
2222
11111
2. Write a program to check whether the given input is digit or lowercase character or
uppercase character or a special character (use 'if-else-if' ladder)
Program:
ch = input("Enter a character: ")
if ch.isdigit():
print("Digit")
elif ch.isupper ():
print("Uppercase character")
elif ch.islower ():
print("Lowercase character")
else:
print("Special character")
Output 1:
Enter a character: 5
Digit
Output 2:
Enter a character: x
Lowercase character
Output 3:
Enter a character: A
Uppercase character
Output 4:
Enter a character: &
Special character
3.python program to point the Fibonacci sequence using while loop
Program:
n=int(input("enter the number of terms:"))
a,b=0,1
count=0
if n<=0:
print("please enter a positive integer,do not enter negative number complex number")
elif n==1:
print("fibonacci sequence upto",n, "terms")
print(a)
else:
print("fibonacci sequence")
while count<n:
print(a,end=' ')
nth=a+b
a=b
b=nth
count=count+1
output:
enter the number of terms:10
fibonacci sequence
0 1 1 2 3 5 8 13 21 34
4 . python program to print all prime numbers in a given interval (use break)
Program:
lower=int(input("enter the lower range:"))
upper=int(input("enter the upper range:"))
print("prime number between",lower,"and",upper,"are:")
for num in range(lower,upper+1):
if num>1:
for i in range(2,num):
if (num%i)==0:
break
else:
print(num,end=' ')
output:
enter the lower range:5
enter the upper range:50
prime number between 5 and 50 are:
5 7 11 13 17 19 23 29 31 37 41 43 47
Week-3
1.i) Write a program to convert a list and tuple into arrays. Program:
import numpy as np
my_list = [1, 2, 3, 4, 5, 6, 7, 8]
print("List to array: ")
list_array = np.asarray(my_list)
print(list_array)
my_tuple = ([8, 4, 6], [1, 2, 3])
print("Tuple to array: ")
tuple_array = np.asarray(my_tuple)
print(tuple_array)
Output 1:
List to array:
[1 2 3 4 5 6 7 8]
Tuple to array:
[[8 4 6]
[1 2 3]]
ii) Write a program to find common values between two arrays
program:
import numpy as np
ar1 = [0, 1, 2, 3, 4, 7, 10]
ar2 = [10, 3, 4, 5, 6, 7]
print("array1 : ",ar1)
print("array2 : ",ar2)
print("Common values : ")
print(np.intersect1d(ar1, ar2))
output:
array1 : [0, 1, 2, 3, 4, 7, 10]
array2 : [10, 3, 4, 5, 6, 7]
Common values :
[ 3 4 7 10]
2. Write a function called gcd that takes parameters a and b and returns their greatest
common divisor.
Program:
# Python code to compute gcd using Euclidean method( recursion )
def gcd(a,b):
if(b!=0):
return gcd(b,a%b)
else:
return a
a=int(input("enter the first number:"))
b=int(input("enter the second number:"))
print("the gcd of",a,"and",b,"is:",gcd(a,b))
output:
enter the first number:60
enter the second number:45
the gcd of 60 and 45 is: 15
3. Write a function called palindrome that takes a string argument and returns True if it
is a palindrome and False otherwise. (Remember that you can use the built-in function
len to check the length of a string.)
Program:
def palindrome(string):
pal_string = string.casefold()
rev_string = reversed(pal_string)
if list(pal_string) == list(rev_string):
print("PALINDROME!")
else:
print("NOT PALINDROME!")
print(palindrome('madam'))
output:
PALINDROME!
WEEK-4
1.Write a function called is_sorted that takes a list as a parameter and returns True if
the list is sorted in ascending order and False otherwise.
Program:
def is_sorted(a):
print("Given List is : ",a)
for i in range(len(a)-1):
if a[i] > a[i+1]:
return False
return True
if (is_sorted([31,42,53,74,95,96])):
print("List is in sorted")
else:
print("List is not sorted")
output1:
Given List is : [31, 42, 53, 74, 95, 96]
List is in sorted
Output2:Given List is : [31, 42, 53, 74, 15, 96]
List is not sorted
2. Write a function called has_duplicates that takes a list and returns True if there is any
element that appears more than once. It should not modify the original list.
Program:
def has_duplicates(source):
return len(set(source)) != len(source)
print(has_duplicates([1,2,3,4,4,5,6,7,8]))
output:
Output 1: True
Output 2: False (if the function call is print(has_duplicates([1,2,3,4,5,6,7,8])))
i). Write a function called remove_duplicates that takes a list and returns a new list with
only the unique elements from the original. Hint: they don’t have to be in the same
order.
Program:
def Remove(duplicate):
final_list = []
for num in duplicate:
if num not in final_list:
final_list.append(num)
return final_list
duplicate = [2, 4, 10, 20, 5, 2, 20, 4]
print(Remove(duplicate))
output:
[2, 4, 10, 20, 5]
ii). The wordlist I provided, words.txt, doesn’t contain single letter words. So you might
want to add “I”, “a”, and the empty string.
Program:
with open("C:/Users/Nagam Bhaskar Reddy/Downloads/word.txt","w") as file:
file.write("I ")
file.write("a")
output:
iii). Write a python code to read dictionary values from the user. Construct a function to
invert its content. i.e., keys should be values and values should be keys.
Program:
n = int(input("Enter the no of entries you want to enter : "))
dict = {}
for i in range(n):
key = int(input("Enter the key : " ))
value = input("Enter the value : ")
dict[key]=value
print(dict)
newdict={}
for pair in dict.items():
newdict[pair[1]]=pair[0]
print(newdict)
output:
Enter the no of entries you want to enter : 4
Enter the key : 1
Enter the value : a
Enter the key : 2
Enter the value : b
Enter the key : 3
Enter the value : c
Enter the key : 4
Enter the value : d
{1: 'a', 2: 'b', 3: 'c', 4: 'd'}
{'a': 1, 'b': 2, 'c': 3, 'd': 4}
3. i) Add a comma between the characters. If the given word is 'Apple', it should become
'A,p,p,l,e'
Program:
txt = "apple"
commas_added = ','.join(txt)
print(commas_added)
output:
a,p,p,l,e
ii) Remove the given word in all the places in a string?
Program:
print("Enter the String: ")
text = input()
print("Enter a Word to Delete: ")
word = input()
text = text.replace(word, "")
print()
output:
Enter the String:
hai my name is bhuvana
Enter a Word to Delete:
name
hai my is bhuvana
iii) Write a function that takes a sentence as an input parameter and replaces the first
letter of every word with the corresponding upper case letter and the rest of the letters
in the word by corresponding letters in lower case without using a built-in function?
Program:
txt=input("Enter a sentence:")
print(txt.title())
Output : Enter a sentence: hello, welcome to rishi
Hello, Welcome To Rishi
4. Writes a recursive function that generates all binary strings of n-bit length
Program:
def printTheArray(arr, n):
for i in range(0, n):
print(arr[i], end = " ")
print()
def generateAllBinaryStrings(n, arr, i):
if i == n:
printTheArray(arr, n)
return
arr[i] = 0
generateAllBinaryStrings(n, arr, i + 1)
arr[i] = 1
generateAllBinaryStrings(n, arr, i + 1)
if __name__ == "__main__":
n=4
arr = [None] * n
generateAllBinaryStrings(n, arr, 0)
output:
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
WEEK-5
1 i) Write a python program that defines a matrix and prints
Program:
row=int(input("Enter No of Rows for 1st Matrix:"))
column=int(input("Enter No of column for 1st Matrix:"))
row1=int(input("Enter No of Rows for 2nd Matrix:"))
column1=int(input("Enter No of column for 2nd Matrix:"))
X = [[int(input(("Enter value for X[",i,"][",j,"]:")))
for j in range(column)] for i in range(row)]
Y = [[int(input(("Enter value for Y[",i,"][",j,"]:")))
for j in range(column1)] for i in range(row1)]
print("1st Matrix X:",X)
print("2nd Matrix Y:",Y)
output:
Enter No of Rows for 1st Matrix:3
Enter No of column for 1st Matrix:3
Enter No of Rows for 2nd Matrix:3
Enter No of column for 2nd Matrix:3
('Enter value for X[', 0, '][', 0, ']:')1
('Enter value for X[', 0, '][', 1, ']:')1
('Enter value for X[', 0, '][', 2, ']:')1
('Enter value for X[', 1, '][', 0, ']:')2
('Enter value for X[', 1, '][', 1, ']:')2
('Enter value for X[', 1, '][', 2, ']:')2
('Enter value for X[', 2, '][', 0, ']:')3
('Enter value for X[', 2, '][', 1, ']:')3
('Enter value for X[', 2, '][', 2, ']:')3
('Enter value for Y[', 0, '][', 0, ']:')4
('Enter value for Y[', 0, '][', 1, ']:')4
('Enter value for Y[', 0, '][', 2, ']:')4
('Enter value for Y[', 1, '][', 0, ']:')5
('Enter value for Y[', 1, '][', 1, ']:')5
('Enter value for Y[', 1, '][', 2, ']:')5
('Enter value for Y[', 2, '][', 0, ']:')6
('Enter value for Y[', 2, '][', 1, ']:')6
('Enter value for Y[', 2, '][', 2, ']:')6
1st Matrix X: [[1, 1, 1], [2, 2, 2], [3, 3, 3]]
2nd Matrix Y: [[4, 4, 4], [5, 5, 5], [6, 6, 6]]
ii) Write a python program to perform addition of two square matrices
Program:
import numpy as np
X = [[1,2,3],
[4 ,5,6],
[7 ,8,9]]
Y = [[9,8,7],
[6,5,4],
[3,2,1]]
result = np.array(X) + np.array(Y)
print(result)
output:
[[10 10 10]
[10 10 10]
[10 10 10]]
iii) Write a python program to perform multiplication of two square matrices
Program:
X = [[12,7,3],
[4 ,5,6],
[7 ,8,9]]
Y = [[5,8,1,2],
[6,7,3,0],
[4,5,9,1]]
result = [[0,0,0,0],
[0,0,0,0],
[0,0,0,0]]
for i in range(len(X)):
for j in range(len(Y[0])):
for k in range(len(Y)):
result[i][j] += X[i][k] * Y[k][j]
for r in result:
print(r)
output:
[114, 160, 60, 27]
[74, 97, 73, 14]
[119, 157, 112, 23]
2. Use the structure of exception handling all general purpose exceptions
Program:
try:
even_numbers = [2,4,6,8]
print(even_numbers[5])
except ZeroDivisionError:
print("Denominator cannot be 0.")
except IndexError:
print("Index Out of Bound.")
output:
Index Out of Bound.
Week-6:
1. a. Write a function called draw_rectangle that takes a Canvas and a Rectangle as
arguments and draws a representation of the Rectangle on the Canvas.
b. Add an attribute named color to your Rectangle objects and modify draw_rectangle
so that it uses the color attribute as the fill color.
c. Write a function called draw_point that takes a Canvas and a Point as arguments and
draws a representation of the Point on the Canvas.
d. Define a new class called Circle with appropriate attributes and instantiate a few
Circle objects. Write a function called draw_circle that draws circles on the canvas
program:
import tkinter as tk
root = tk.Tk()
canvas = tk.Canvas(root, width=400, height=400)
canvas.pack()
canvas.create_rectangle(10, 10, 100, 100, fill='red')
root.mainloop()
output:
2. Write a Python program to demonstrate the usage of Method Resolution Order
(MRO) in multiple levels of Inheritances.
program:
class ClassA:
def m(self):
print("In ClassA")
class ClassB(ClassA):
def m(self):
print("In ClassB")
class ClassC(ClassA):
def m(self):
print("In ClassC")
class ClassD(ClassB, ClassC):
def m(self):
print("In ClassD")
ClassB.m(self)
ClassC.m(self)
ClassA.m(self)
obj = ClassD()
obj.m()
output
In ClassD
In ClassB
In ClassC
In ClassA
2. Write a python code to read a phone number and email-id from the user and validate
it for correctness.
Program:
import re
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
def check(email):
if(re.fullmatch(regex, email)):
print("Valid Email")
else:
print("Invalid Email")
if __name__ == '__main__':
email = "[email protected]"
check(email)
email = "[email protected]"
check(email)
email = "ankitrai326.com"
check(email)
output:
Valid Email
Valid Email
Invalid Email
For mobilenumber:
import re
def validate_phone_number(regex, phone_number):
match = re.search(regex, phone_number)
if match:
return True
return False
pattern = re.compile(r"(\+\d{1,3})?\s?\(?\d{1,4}\)?[\s.-]?\d{3}[\s.-]?\d{4}")
test_phone_numbers = [
"+1 (555) 123-4567",
"555-123-4567",
"555 123 4567",
"+44 (0) 20 1234 5678",
"02012345678",
"invalid phone number"
]
for number in test_phone_numbers:
print(f"{number}: {validate_phone_nu+1 (555) 123-4567: True
555-123-4567: True
555 123 4567: True
+44 (0) 20 1234 5678: True
02012345678: True
invalid phone number: Falsember(pattern, number)}")
output:
+1 (555) 123-4567: True
555-123-4567: True
555 123 4567: True
+44 (0) 20 1234 5678: True
02012345678: True
invalid phone number: False
week-7
1.Write a Python code to merge two given file contents into a third file.
Program:
with open("C://Users//Nagam Bhaskar Reddy//OneDrive//Desktop//file1.txt","r") as fh1:
with open("C://Users//Nagam Bhaskar Reddy//OneDrive//Desktop//file2.txt","r") as
fh2:
with open("C://Users//Nagam Bhaskar
Reddy//OneDrive//Desktop//mergefile.txt","w") as fh3:
q=fh1.readlines()+fh2.readlines()
fh3.writelines(q)
2.Write a Python code to open a given file and construct a function to check for
given words present in it and display on found.
Program:
with open('C://Users//Nagam Bhaskar Reddy//OneDrive//Desktop//file1.txt') as file:
contents = file.read()
search_word = input("enter a word you want to search
in file: ")
if search_word in contents:
print ('word found')
else:
print ('word not found')
output1:
enter a word you want to search in file: information
word found
output2:
enter a word you want to search in file: the
word not found
3. Write a Python code to Read text from a text file, find the word with most
number of occurrences
Program:
file = open("C://Users//Nagam Bhaskar
Reddy//OneDrive//Desktop//file1.txt","r")
frequent_word = ""
frequency = 0
words = []
for line in file:
line_word =
line.lower().replace(',','').replace('.','').split(" ")
for w in line_word:
words.append(w)
for i in range(0, len(words)):
count=1
for j in range(i+1,
len(words)):
if(words[i] == words[j]):
count = count + 1
if(count > frequency):
frequency = count
frequent_word = words[i]
print("Most repeated word: " +frequent_word)
print("Frequency: " +str(frequency))
file.close()
output:
Most repeated word: python
Frequency: 6
4.Write a function that reads a file file1 and displays the number of words,
number of vowels, blank spaces, lower case letters and uppercase letters.
Program:
for i in r:
if i.isalpha():
if
i.isupper():
u=u+1
if i.islower():
l=l+1
if i.isspace():
b=b+1
if i.lower() in ["a","e","i","o","u"]:
v=v+1
else:
c=c+1
print("Number of Uppercase characters
are:",u)
print("Number of Lowercase characters
are:",l)
print("Number of blankspaces:",b)
print("Number of Vowels characters
are:",v)
print("Number of Consonants characters
are:",c)
output:
Number of Uppercase characters are: 8
Number of Lowercase characters are: 96
Number of blankspaces: 0
Number of Vowels characters are: 33
Number of Consonants characters are: 71
Week - 8:
1.Import numpy, Plotpy and Scipy and explore their functionalities.
Program:
#Numpy
import numpy as np
# Initial Array
arr = np.array([[-1, 2, 0, 4],
[4, -0.5, 6, 0],
[2.6, 0, 7, 8],
[3, -7, 4, 2.0]])
print("Initial Array: ")
print(arr)
# Printing a range of Array
# with the use of slicing method
sliced_arr = arr[:2, ::2]
print ("Array with first 2 rows and"
" alternate columns(0 and 2):\n",
sliced_arr)
# Printing elements at
# specific Indices
Index_arr = arr[[1, 1, 0, 3],
[3, 2, 1, 0]]
print ("\nElements at indices (1, 3), "
"(1, 2), (0, 1), (3, 0):\n", Index_arr)
Output:
Initial Array:
[[-1. 2. 0. 4. ]
[ 4. -0.5 6. 0. ]
[ 2.6 0. 7. 8. ]
[ 3. -7. 4. 2. ]]
Array with first 2 rows and alternate columns(0 and 2):
[[-1. 0.]
[ 4. 6.]]
Elements at indices (1, 3), (1, 2), (0, 1), (3, 0):
[0. 6. 2. 3.]
#Pyplot
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# evenly sampled time at 200ms
intervals
t = np.arange(0., 5., 0.2)
# red dashes, blue squares and green
triangles
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
plt.show()
Output:
2.a) Install NumPy package with pip and explore it.
Python NumPy is a general-purpose array processing package which
provides tools
for handling the n-dimensional arrays. Numpy installation through pip:
Syntax: Pip install numpy
Program:
import numpy as np
a=np.array([10,20,30]) #creates a one
dimensional array
print("one dimensional array:",a)
b=np.array([[10,20,30], [40,50,60]]) #creates a
2D array
print("Two dimensional array:",b)
c=np.zeros((3,4)) #creates array with all zeros
print("array with all zeros:",c)
d=np.ones((3,4)) #creates array with all ones.
print("array with all zeros:",d)
e=np.full((3,3),5) #creates an array with specified number
print("array with specific number:",e)
g=np.eye(3,dtype=int) #creates an identity matrix
print("Identity Matrx:",g)
print("Dimension:",b.ndim) #gives the dimension of the array
print("Shape of array:",b.shape) #gives the sequence of integers
indicating the size of
thearray for each dimension
print("Size of array:",b.size) #gives the total number of elements of the
array
print("Data typpe of array elements:",b.dtype) #gives data type of the
elements of
thearray
print("Size of each array element in bytes:",b.itemsize) #It specifies the
size in bytes
ofeach element of the array
output:
one dimensional array: [10 20 30]
Two dimensional array: [[10 20 30]
[40 50 60]]
array with all zeros: [[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]]
array with all zeros: [[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]]
array with specific number: [[5 5 5]
[5 5 5]
[5 5 5]]
Identity Matrx: [[1 0 0]
[0 1 0]
[0 0 1]]
Dimension: 2
Shape of array: (2, 3)
Size of array: 6
Data typpe of array elements: int32
Size of each array element in bytes: 4
3.Write a program to implement Digital Logic Gates – AND, OR, NOT, EX-OR
Program:
#Python3 program to illustrate working of AND gate
def AND (a, b):
if a == 1 and b == 1:
return True
else:
return False
# Driver code
if __name__ =='__main__':
print(AND(1, 1))
print("+ + +")
print(" | AND Truth Table | Result |")
print(" A = False, B = False | A AND B
=",AND(False,False)," | ")
print(" A = False, B = True | A AND B
=",AND(False,True)," | ")
print(" A = True, B = False | A AND B
=",AND(True,False)," | ")
print(" A = True, B = True | A AND B
=",AND(True,True)," | ")
# Python3 program to illustrate working of OR gate
def OR(a, b):
if a == 1 or b ==1:
return True
else:
return False
# Driver code
if __name__ =='__main__':
print(OR(0, 0))
print("+ + +")
print(" | OR Truth Table | Result |")
print(" A = False, B = False | A OR B
=",OR(False,False)," | ")
print(" A = False, B = True | A OR B
=",OR(False,True)," | ")
print(" A = True, B = False | A OR B
=",OR(True,False)," | ")
print(" A = True, B = True | A OR B =",OR(True,True),"
| ")
# Python3 program to illustrate working of Xor gate
def XOR (a, b):
if a != b:
return 1
else:
return 0
# Driver code
if __name__ =='__main__':
print(XOR(5, 5))
print("+ + +")
print(" | XOR Truth Table | Result |")
print(" A = False, B = False | A XOR B
=",XOR(False,False)," | ")
print(" A = False, B = True | A XOR B
=",XOR(False,True)," | ")
print(" A = True, B = False | A XOR B
=",XOR(True,False)," | ")
print(" A = True, B = True | A XOR B
=",XOR(True,True)," | ")
# Python3 program to illustrate working of Not gate
def NOT(a):
return not a
# Driver code
if __name__ =='__main__':
print(NOT(0))
print("+ + +")
print(" | NOT Truth Table | Result |")
print(" A = False | A NOT
=",NOT(False)," | ")
print(" A = True, | A NOT
=",NOT(True)," | ")
output:
True
+++
| AND Truth Table | Result |
A = False, B = False | A AND B = False |
A = False, B = True | A AND B = False |
A = True, B = False | A AND B = False |
A = True, B = True | A AND B = True |
False
+++
| OR Truth Table | Result |
A = False, B = False | A OR B = False |
A = False, B = True | A OR B = True |
A = True, B = False | A OR B = True |
A = True, B = True | A OR B = True |
0
+++
| XOR Truth Table | Result |
A = False, B = False | A XOR B = 0 |
A = False, B = True | A XOR B = 1 |
A = True, B = False | A XOR B = 1 |
A = True, B = True | A XOR B = 0 |
True
+++
| NOT Truth Table | Result |
A = False | A NOT = True |
A = True, | A NOT = False |
4. Write a program to implement Half Adder, Full Adder, and Parallel Adder
Program:
# Half adder
import numpy as np
def half_adder(A, B):
Sum = np.bitwise_xor(A,
B)
Carry =
np.bitwise_and(A, B)
return Sum, Carry
# Driver code
A=0
B=1
Sum, Carry = half_adder(A,
B)
print("Half Adder:")
print("Sum:", Sum)
print("Carry:", Carry)
output:
Half Adder:
Sum: 1
Carry: 0
5.Write a GUI program to create a window wizard having two text labels, two
text fields and two buttons as Submit and Reset
Program:
from tkinter import *
window=Tk()
usernamelabel1=Label(window,text="User
Name:").grid(row=0,column=0)
usernameEntry=Entry(window).grid(row=0,column=1)
passwordlabel1=Label(window,text="Password:").grid(row=1,col
umn=0)
usernameEntry=Entry(window).grid(row=1,column=1)
submitButton=Button(window,text="Submit").grid(row=2,colum
n=0)
resetButton=Button(window,text="Reset").grid(row=2,column=
1)
window.mainloop()
output: