Abhinav and Anjali are playing Rock-Paper-Scissors game. Rock-Paper-Scissors is a hand game usually played between two people, in which each player simultaneously forms one of three shapes with an outstretched hand. These shapes are "rock", "paper" and "scissors". Based on the shapes the player chooses the outcome of the game is determined. A rock beats scissors, scissors beat paper by cutting it, and paper beats rock by covering it. If the same shape is chosen by both of the players, then it is a tie. Write a program to decide the winner of each round of the game based on the shapes the players chose.
Given Inputs:
code and explanation for this question
The given question is (Given a string in camel case, write a python program to convert the given string from camel case to snake case.)
Given inputs
I need code and explanation for this question........?
Add two polynomials
Given two polynomials A and B, write a program that adds the given two polynomials A and B
The first line contains a single integer M.
Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A.
After that next line contains a single integer N.
Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.Output
Print the addition of polynomials A and B.
If the degree of polynomial is zero and the constant term is also zero, then just print 0 to represent the polynomial.
For term Cix^Pi, if the coefficient of the term Ci is 1, simply print x^Pi instead of 1x^Pi.Explanation
Sample Input
6
0 -20
1 23
2 30
3 19
4 6
5 17
9
0 -100
5 -89
6 -20
7 -1
1 20
2 4
3 99
4 -45
8 12
Sample Output
12x^8 - x^7 - 20x^6 - 72x^5 - 39x^4 + 118x^3 + 34x^2 + 43x - 120
Mean, Median and Mode
Given a list of integers, write a program to print the mean, median and mode.
Mean - The average value of all the numbers.
Median - The mid point value in the sorted list.
Mode - The most common value in the list. If multiple elements with same frequency are present, print all the values with same frequency in increasing order.
See Sample Input/Output for the output format.
Sample Input 1
2 4 5 6 7 8 2 4 5 2 3 8
Sample Output 1
Mean: 4.67
Median: 4.5
Mode: 2
Sample Input 2
2 6 3 1 8 12 2 9 10 3 4
Sample Output 2
Mean: 5.45
Median: 4
Mode: 2 3
The output should be in this function format given below :
def find_mean(num_list):
# Complete this function
def find_median(num_list):
# Complete this function
def find_mode(num_list):
# Complete this function
num_list = list(map(int, input().split()))
# Call the appropriate functions and print the results
Secret Message - 2
Given a string, write a program to print a secret message that replaces characters with numbers 'a' with 1, 'b' with 2, ..., 'z' with 26 where characters are separated by '-'.
a b c d e f g h i j k l m n o p q r s t u v w x y z
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
Input
Input will be a string in single line containing spaces and letters both uppercase and lowercase.
Output
Output should be a single line containing secret message. All characters in output should be in lower case.
Explanation
For example, if given input is "python", "p" should replaced with "16", similarly"y" with "25","t" with "20","h" with "8","o" with "15","n" with "14". So output should be "16-25-20-8-15-14".
Sample Input 1
python
Sample Output 1
16-25-20-8-15-14
Sample Input 2
Foundations
Sample Output 2
6-15-21-14-4-1-20-9-15-14-19
Create a Python class named BankAccount which represents a bank account with the following attributes: numAccount, name (name of the owner of the account) and balance. 1. Create the constructor (__init__ method) 2. Create a method deposit() which manages payments. 3. Create a withdrawal() method that handles withdrawals. 4. Create a display() method that displays the details of the account 5. Create an instance of the class BankAccount and call the three methods defined.
You have been given an encrypted copy of the Final exam study guide here, but how do you decrypt and read it???
Along with the encrypted copy, some mysterious person has also given you the following documents:
helloworld.txt -- Maybe this file decrypts to say "Hello world!". Hmmm.
Given a sentence as input, print all the unique combinations of the words of the sentence, considering different possible number of words each time (from one word to N unique words in lexicographical order).Input
The input will be a single line containing a sentence.Output
The output should be multiple lines, each line containing the unique combination from one word to N words in lexicographical order.Explanation
For example, if the given sentence is "apple is a fruit".
All possible one-word unique combinations are
a
apple
fruit
isAll possible two words unique combinations are
a apple
a fruit
a is
apple fruit
apple is
fruit isAll possible three words unique combinations are
a apple fruit
a apple is
a fruit is
apple fruit isAll possible four words unique combinations are
a apple fruit isSample Input 1
apple is a fruit
Sample Output 1
a
apple
fruit
is
a apple
a fruit
a is
apple fruit
apple is
fruit is
a apple fruit
a apple is
a fruit is
apple fruit is
a apple fruit is
Given a sentence as input, print all the unique combinations of N words in lexicographical order.Input
The first line of input will be containing a sentence.
The second line of input will contain a positive integer.Output
The output should be multiple lines, each line containing the unique combination of N words in lexicographical order.Explanation
For example, if the given sentence is "apple is a fruit", and N is 3, the possible unique combination of three words are (a, apple, fruit), (a, apple, is), (a, fruit, is), (apple, fruit, is). So the output should be
a apple fruit
a apple is
a fruit is
apple fruit isSample Input 1
apple is a fruit
3
Sample Output 1
a apple fruit
a apple is
a fruit is
apple fruit is
Sample Input 2
raju plays cricket
2
Sample Output 2
cricket plays
cricket raju
plays raju
Given a sentence as input, print all the unique combinations of three words in lexicographical order.Input
The input will be a single line containing a sentence.Output
The output should be multiple lines, each line containing the unique combination of three words in lexicographical order.Explanation
For example, if the given sentence is "apple is a fruit", the possible unique combination of three are (a, apple, fruit), (a, apple, is), (a, fruit, is), (apple, fruit, is). So the output should be
a apple fruit
a apple is
a fruit is
apple fruit isSample Input 1
apple is a fruit
Sample Output 1
a apple fruit
a apple is
a fruit is
apple fruit is
Sample Input 2
raju plays cricket
Sample Output 2
cricket plays raju