Python Session 2 Task
Python Session 2 Task
Problem 2: Write a program that take a user input of three angles and
will find out whether it can form a triangle or not.
# Write code here
Problem 3: Write a program that will take user input of cost price and
selling price and determines whether its a loss or a profit.
# Write code here
The factorial (symbol: !) means to multiply all whole numbers from the chosen number down to
1.
Output:
120
76542
Output:
24567
Problem 8: Take a user input as integer N. Find out the sum from 1 to N.
If any number if divisible by 5, then skip that number. And if the sum is
greater than 300, don't need to calculate the sum further more. Print
the final result. And don't use for loop to solve this problem.
Example 1:
Input:
30
Output:
276
###Problem 10: Write a program, which will find all such numbers between 1000 and 3000
(both included) such that each digit of the number is an even number. The numbers obtained
should be printed in a space-separated sequence on a single line.
###Problem 11: A robot moves in a plane starting from the original point (0,0). The robot can
move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is
shown as the following:
UP 5
DOWN 3
LEFT 3
RIGHT 2
!
Please write a program to compute the distance from current position after a sequence of
movement and original point.
Input:
UP 5
DOWN 3
LEFT 3
RIGHT 2
!
Output:
###Problem 12:Write a program to print whether a given number is a prime number or not
# Write code here
###Problem 13:Print all the Armstrong numbers in a given range. Range will be provided by
the user Armstrong number is a number that is equal to the sum of cubes of its digits. For
example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.
###Problem 14:Calculate the angle between the hour hand and minute hand.
Note: There can be two angles between hands; we need to print a minimum of two. Also, we
need to print the floor of the final result angle. For example, if the final angle is 10.61, we need to
print 10.
Input: H = 9 , M = 0 Output: 90 Explanation: The minimum angle between hour and minute hand
when the time is 9 is 90 degress.
###Problem 15:Given two rectangles, find if the given two rectangles overlap or not. A
rectangle is denoted by providing the x and y coordinates of two points: the left top corner and
the right bottom corner of the rectangle. Two rectangles sharing a side are considered
overlapping. (L1 and R1 are the extreme points of the first rectangle and L2 and R2 are the
extreme points of the second rectangle).
Note: It may be assumed that the rectangles are parallel to the coordinate axis.