Python Answers

Questions answered by Experts: 5 288

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

3. Sum Cubes


by CodeChum Admin


The square of an integer refers to the result of multiplying the integer with itself once. While the cube of an integer refers to the result of multiplying the integer with itself twice. As long as you know that, you could easily solve this!



Instructions:


Input three integers and compute the cubes of each of them.

Check if the sum of the cubes are positive. If it is, print out "Positive", and if not, print out "Negative".


Instructions


Input three integers (negative, positive, or zero) and compute the cubes of each of them.

Check if the sum of the cubes are positive. If so, print out "Positive", and if not, print out "Negative".


Input


A line containing three integers separated by a space.


1 2 3


Output


A line containing a string.


Positive


Input The input will be three lines contain O's and X's separated by space. Output The output should be a single line containing either "Abhinav Wins" or "Anjali Wins" or "Tie". Explanation For example, if the input is O X O O X X O O X as three of O's are in vertical row print "Abhinav Wins". Sample Input 1 O X O O X X O O X Sample Output 1 Abhinav Wins Sample Input 2 O O X X X O X O O Sample Output 2 Anjali Wins
Numbers in String - 1 Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.Input The input will be a single line containing a string.Output The output should contain the sum and average of the digits of all numbers that appear in the string. Note: Round the average value to two decimal places.Explanation For example, if the given string is "I am 25 years and 10 months old", the digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line. Sample Input 1 I am 25 years and 10 months old Sample Output 1 8 2.0 Sample Input 2 Tech Foundation 35567 Sample Output 2 26 5.2
Numbers in String - 1 Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.Input The input will be a single line containing a string.Output The output should contain the sum and average of the digits of all numbers that appear in the string. Note: Round the average value to two decimal places.Explanation For example, if the given string is "I am 25 years and 10 months old", the digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line. Sample Input 1 I am 25 years and 10 months old Sample Output 1 8 2.0 Sample Input 2 Tech Foundation 35567 Sample Output 2 26 5.2
First Perfect Square Given two integers (M and N), write a program to print the first perfect square in a given range.Input The first line of input will contain a positive integer (M). The second line of input will contain a positive integer (N).Output The output should be a single line containing the first perfect square in a given range.Explanation For example, if the given numbers are M is 4 and N is 16, the perfect squares from 4 to 16 are 4(2 * 2), 9(3 * 3), and 16(4 * 4), as the first perfect square is 4. So the output should be 4. Sample Input 1 4 16 Sample Output 1 4 Sample Input 2 5 8 Sample Output 2 No Perfect Square
String Rotation Given two strings(S1 and S2), write a program to determine if a string S2 is a rotation of another string S1. Input The first line of the input will be a string S1. The second line of the input will be a string S2.Output If string S2 is a rotation of another string S1, print number of right rotations made by string S1 to match the string S2. Otherwise, print "No Match". Where right rotation means all elements are moving towards the right side by one place where the last element will be placed in the first place example, one right rotation of "python" is "npytho" For example, if the given strings S1 and S2 are "python" and "onpyth", The first right rotation of s1 is "npytho" which is not equal to string S2"onpyth" The second right rotation of s2 is "onpyth" which is equal to string S2 "onpyth". So output 2 Sample Input 1 python onpyth Sample Output 1 2 Sample Input 2 Python Python Sample Output 2 0

Write a Python function, named “find_fibonacci”, which accepts a list as input.  The function will find and return the elements that satisfy the Fibonacci property: 


Example : Input list : [2, 8, 4, 6, 1, 7, 8, 4, 7, 9, 4, 13]  

Returned list : [[6,1,7], [1,7,8], [9,4,13]]   




Write Python code that uses nested loops to display the following pattern:

1

1 2 1

1 2 4 2 1

1 2 4 8 4 2 1

1 2 4 8 16 8 4 2 1

.

.

.

1 2 4 8 16 32 64 128 64 32 16 8 4 2 1


Write a Python function that finds and prints all the prime numbers, pn, that satisfy the following equation: pn=2k+3L

for some non-negative integers k,L, such that k≤16, L≤16.


You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on matrix A. Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees. Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z. After the update, all the previous rotation operations have to be applied to the updated initial matrix. Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A. Sample Input: 2 5 6 7 8 R 90 Q 0 1 R 270 Q 1 1 R 180 U 0 0 4 Q 0 0 -1 Sample Output: 5 8 8
LATEST TUTORIALS
APPROVED BY CLIENTS