-
Notifications
You must be signed in to change notification settings - Fork 0
/
Machine test.txt
111 lines (76 loc) · 2.88 KB
/
Machine test.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#1. A website requires the users to input username and password to register.
#Write a program to check the validity of password input by users.
'''def password():
while True:
for i in c:
if 6<=len(i)<=12 and re.search("[A-Za-z0-9!@#$%^&*]",i) :
print(i)
return
import re
p=input("enter the passwords")
c=p.split(",")
print(c)
password()'''
#2.Given an positive integer n, if you apply the following rules iteratively, you will eventually get a 1.
'''n=(int(input("Enter the number")))
print("you have entered:",n)
l=[]
l.append(n)
while n > 1:
if n %2==0:
n=n/2
else:
n=(3*n)+1
l.append(n)
print(l)'''
#3.Create a simple calculator GUI app using TKinter framework.
'''import tkinter as tk
class Calculator:
def __init__(self, m):
self.m = m
m.title("Calculator")
self.display = tk.Entry(m, width=30, justify='right')
self.display.grid(row=0, column=0, columnspan=4, padx=5, pady=5)
buttons = [
'7', '8', '9', '/',
'4', '5', '6', '*',
'1', '2', '3', '-',
'0', '.', '=', '+'
]
for row in range(1, 5):
for col in range(4):
index = (row - 1) * 4 + col
if buttons[index] == '=':
button = tk.Button(m, text='=', width=10, height=3, command=lambda: self.calculate())
else:
button = tk.Button(m, text=buttons[index], width=10, height=3, command=lambda value=buttons[index]: self.add_to_display(value))
button.grid(row=row, column=col, padx=5, pady=5)
clearbutn = tk.Button(m, text='C', width=10, height=3, command=lambda: self.clear_display())
clearbutn.grid(row=5, column=0, columnspan=3, padx=5, pady=5)
def add_to_display(self, value):
self.display.insert(tk.END, value)
def clear_display(self):
self.display.delete(0, tk.END)
def calculate(self):
try:
result = eval(self.display.get())
self.display.delete(0, tk.END)
self.display.insert(tk.END, result)
except:
self.display.delete(0, tk.END)
self.display.insert(tk.END, "Error")
root = tk.Tk()
calculator = Calculator(root)
root.mainloop()'''
#4.The denominations in Indian currency are: |1, |2, |5, |10, |,20, |50, |100, |200, |500, |2000.
# Given an amount N, print how many coins/notes make up N Sample input
'''d= [2000, 500, 200, 100, 50, 10, 5, 2, 1]
n = int(input("Enter the amount: "))
c = [0] * len(d)
for i in range(len(d)):
c[i] = n // d[i]
n = n % d[i]
print("Denominations and number of coins/notes:")
for i in range(len(d)):
if c[i] != 0:
print("|" + str(d[i]) + ":", c[i])'''