integers = [int(number) for number in input().split()]
K = int(input())
triplets = []
for i in range(len(integers)):
for j in range(i+1,len(integers)):
for k in range(j+1, len(integers)):
a = integers[i]
b = integers[j]
c = integers[k]
if a+b+c == K:
triplets.append(tuple((a,b,c))) input:0 12 17 8 9 21
sorted_triplets=[] 29
for tripl in triplets:
item = sorted(tripl) output:[0, 8, 21]
sorted_triplets.append(item) [0, 12, 17]
triplets= sorted(sorted_triplets) [8, 9, 12]
if len(triplets)!=0:
for triplet in triplets: output should be like this:(0, 8, 21)
triplet=sorted(triplet) (0, 12, 17)
print(triplet) (8, 9, 12)
else: output should be in round braces
print("No Matching Triplets Found")
Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.
For example, if the given M and N are 4 and 4 respectively. If the matrix elements are
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
If the given K is 3. Rotate each ring of the matrix by 3 elements.
In the above matrix, the elements (1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5) is a ring, similarly, the elements (6, 7, 11, 10) will make a ring.
Therefore, by rotating each ring in clockwise direction by 3 elements will give (13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14) and (10, 6, 7, 11). So the output should be
13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4
input:4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3
output should print like this:13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4
H/w question 6
Create a program in Python, called Tri-Calculator, that uses a function to calculate the area of a triangle given the base and height measurements. Use the below function to do your calculation:
def area_of_triangle (base, height); return 0.5 * base * height
The program should receive the base and the height from the user. Once the user enter a base greater than the height the program should give the user another attempt to enter a base and a height. The program only give the user three attempts to enter the correct base and height on the third attempt the program should display the below message:
"Your 3 attempts is up, try again later"
If the user enters a base less than height, the program should display the correct triangle area using the given function.
(it should contain a function, loop, if statement and sentinel value)
Develop User Interface as mentioned below as per the requirements:
Button One: Activate Button Two: Deactivate
Button One is pressed two fields and a button appear
Field 1: From Number Field 2: To Number
Button: Activate
Field 1 should auto-populate with the number queried from DB. And should not be changeable. The reason to still have a field is just to make it explicit what is happening.
When the Activate Button is pressed execute some action with parameter as below.
CALLACTION = "Call Forwarding On"
PHONENUMBER = From Number (From Field 1)
TOLLNUMBER = To Number (From Field 2)
Button Two is pressed a prompt and two buttons appear.
Prompt: "Are you sure you would like to deactivate the <Telephone Number>?" Where <Telephone Number> is the number initially queried.
Button 1: Yes Button 2: No
Input format:
The first line contains of 4 space separated integers. N(1<=N<=10^3), M(N-1<=M<=(N(N-1)/2).T(1<=T<=10^3) and c(1<=C<=10^3). Next m line contains two integers each. U and V denoting that there is a bidirectional road between U and V.
Output format :
Print N integers, where i th denotes the number of routes which will take the minimum amount of time required to move from city 1 to city N passing through the city i
Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.Input
The first line of input will contain two space-separated integers, denoting the M and N.
The next M following lines will contain N space-separated integers, denoting the elements of each list.Output
The output should be M lines containing the ordered matrix.
Note: There is a space at the end of each line.Explanation
For example, if the given M is 3 and N is 3, read the inputs in the next three lines if the numbers given in the next three lines are the following.
3 3
1 20 3
30 10 2
5 11 15By ordering all the elements of the matrix in increasing order, the ordered matrix should be
1 2 3
5 10 11
15 20 302nd example
2 5
-50 20 3 25 -20
88 17 38 72 -10
result will be
-50 -20 -10 3 17
20 25 38 72 88 *** import numpy should not be used
Each user has 100 credits, the user needs to input credits under 100 and the system needs to take the amount the user played and subtract that from the amount of credits the user had, then 3 numbers need to be randomly generated and the machine needs to check if the 3 numbers are the same. If it is the same the user wins double the credits than what they had and is added to the amount of credits they have. If yes to go again, if they won the credits must be added to start again but if they lost, credits must be lost.
integers = [int(number) for number in input().split()]
K = int(input())
triplets =[]
for i in range(len(integers)):
for j in range(i+1,len(integers)):
for k in range(j+1, len(integers)):
a = integers[i]
b = integers[j]
c = integers[k]
if a+b+c == K:
triplets.append(tuple((a,b,c))
sorted_triplets=[]
for tripl in triplets:
item = sorted(tripl)
sorted_triplets.append(item)
triplets= sorted(sorted_triplets) output:[0, 8, 21] output should be like this:(0, 8, 21)
[0, 12, 17] (0, 12, 17)
[8, 9, 12] (8, 9, 12)
if len(triplets)!=0:
for triplet in triplets:
triplet=sorted(triplet)
print(triplet)
else:
print("No Matching Triplets Found")
def rotateMatrix(mat):
if not len(mat):
return
top = 0
bottom = len(mat)-1
left = 0
right = len(mat[0])-1
while left < right and top < bottom:
prev = mat[top+1][left]
for i in range(left, right+1):
curr = mat[top][i]
mat[top][i] = prev
prev = curr
top += 1
for i in range(top, bottom+1):
curr = mat[i][right]
mat[i][right] = prev
prev = curr
right -= 1
output:[13, 9, 5, 1]
[14, 7, 11, 2,]
[15, 6, 10, 3]
[16 ,12, 8, 4]
output should be like this:
13, 9, 5, 1
14, 7, 11, 2
15, 6, 10, 2
16, 12, 8,
You are required to develop a Multiple Document Interface application for the following scenario:
An MDI consists of a main window with a menu bar, toolbar and central workspace widget. You are required to develop a basic tourism event management application for your community that displays information of events,venues and bookings(reservation).Dates and start times are required for the events.Venue capacity, address and contact detail of event manager must be recorded for each venue.Client information in terms of name, and contact details must also be managed by your program.Store all your data in text files.
Make use of at least of the following widget.
QMenubar
QFileDialog
Any widgets used to date that may be usefull