For example, suppose that one serving of Sambar takes 500 g of tomato and 300 g of onion. Suppose that you have a 900 g package of tomato and a 660 g package of onion. You could form these into a kit that makes two servings of Sambar. To make two servings, 1000 g of tomato and 600 g of onion are required. Since the 900 g of tomato you have is within [90, 110]% of the 1000 g of tomato required, and the 660 g of onion you have is within [90, 110]% of the 600 g of onion required, this is acceptable. However, you could not say that the kit makes one or three servings of Sambar, nor could you say that it makes 1.999 servings (the number of servings must be an integer).
Write a program to print a pyramid of N rows
+ + + + * + + + +
+ + + * * * + + +
+ + * * * * * + +
Combine Two Dictionaries Write a program to combine two dictionaries updating values for common keys. Input The first line of input will contain space-separated strings, denoting the keys of first dictionary. The second line of input will contain space-separated integers, denoting the values of first dictionary. The third line of input will contain space-separated strings, denoting the keys of second dictionary. The fourth line of input will contain space-separated integers, denoting the values of second dictionary. Output The output should be a single line containing the list of tuples of dictionary items with all the key-value pairs of two dictionaries sorted in ascending order by key.
Given two integers a and b, your task is to calculate and print the following four values:-
a+b
a-b
a*b
a/b using python
Family List:
A list of words is called the Family if the words in the list follow the following rule.
we should be able to obtain each word in the list by
-changing exactly one letter from the previous word in the list
-or , by adding exactly one letter to the previous word in the list
-or ,by removing exactly one letter from the previous word in the list
Given a list of words ,determine if the list is a Family or Not a Family
input:
The first line of input is an integer T representing the number of test cases
the first line of each test case has an integer N representing the total number of words
The second line contains N space separated strings
INPUT:
3
3
hip hop top
3
hip top hop
4
teat treat greet meet
output:
family
not a family
not a family
i/p:
3
3
tic tac toe
2
tic tac
3
tet treat greet
o/p:
not a family
family
not a family
You are on the top floor of a multiplex complex and want to go the ground floor,The lift is not working so you have to search for the staircase on each floor and go down to the exit.
As you are new to that multiplex,you have taken the floor map.you are given a map. M of building in a 2D matrix.
. All walkable space are represented by a 0
. Staircases are represented by a 1
.your starting position is represented by 2 and can be at any level of the car park
.Exit is always at the bottom right of the ground floor
. you must use the staircases 1 s to go down a level
.Each floor will have only one staircase apart from the ground floor which will not have any staircases.find the quickest route of the multiplex complex
input:the first line of input contains two space separated integer N representing the number of rows and C representing the number of columns
the next N lines contain C space-separated integers
I/P: 3 3
1 0 2
0 1 0
0 0 0
O/P:L2 D1 R1 D1 R1
Family List:
A list of words is called the Family if the words in the list follow the following rule.
we should be able to obtain each word in the list by
-changing exactly one letter from the previous word in the list
-or , by adding exactly one letter to the previous word in the list
-or ,by removing exactly one letter from the previous word in the list
Given a list of words ,determine if the list is a Family or Not a Family
input:
The first line of input is an integer T representing the number of test cases
the first line of each test case has an integer N representing the total number of words
The second line contains N space separated strings
Names and nicknames:
There are N persons in a society .You know the names and nicknames of all of the N people in society. Your task is to determine if there any two persons who have the same name and nickname
input:
The first line of input contains integer N
Each of next N lines contains two space separated strings denoting the name and nickname of person
output:
print YES if there is a pair of people with the same name and nickname otherwise print NO
i/p:
2
3
stephen steve
sato hanako
stephen steve
2
conan kun
subaro kun
o/p:
yes
no
i/P:
2
3
thomas cat
jerry mouse
johny bravo
3
nicolas tesla
saito san
nicolas tesla
o/p:
no
yes
Create a python program that adds, subtract, multiply and divide two numbers. Use conditional keywords, iteration keywords, import keywords, function and structure keywords, and returning keywords on your program. Watch the attached video on this activity for your basis and guidelines.
Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the same number of seasons).
Sort the dictionary by key (least to greatest) and output the results to a file named output_keys.txt. Separate multiple TV shows associated with the same key with a semicolon (;), ordering by appearance in the input file. Next, sort the dictionary by values (alphabetical order), and output the results to a file named output_titles.txt.