Maximum number of handshakes
It was Raj's first day at school. His teacher Anu asked the students to meet every other student in the class and to introduce themselves. The teacher asked them to do handshakes when they meet each other. If there are N number of students in the class then write a program to print the total number of handshakes made by the students.
Input
The first line is a single integer N
Output
Print the value representing total number of handshakes
Explanation
In the given example there are 5 persons. The first person shakes his hand with 4 persons. The second person then shakes his hand with 3 persons. The third person shakes his hand with 2 persons. The fourth person shakes his hand with 1 person.
From this, the number of handshakes = 4 + 3 + 2 + 1
So, the output should be 10
.
Leap Year
Write a program to determine whether the given year Y is a leap year or not. A normal year consists of 365 days. But the time required for Earth to revolve around the Sun is around 365.2425 days. So a "leap year" of 366 days is used once every four years to eliminate the error caused by three normal (but short) years. Any year that is divisible by 4 is usually a leap year: for example, 1988, 1992, and 1996 are leap years.
However, there is still a small error that must be accounted for. To eliminate this error, the calendar considers that a year that is divisible by 100 (for example, 1900) is a leap year only if it is also divisible by 400. For this reason, the following years are not leap years: 1700, 1800, 1900, 2100, 2200, 2300, 2500, 2600, ... This is because they are divisible by 100 but not by 400.
The following years are leap years: 1600, 2000, 2400 This is because they are divisible by both 100 and 400.
Write a program that reads all the match outcomes and summarizes the information of all the matches. A win earns a team 3 points. The team information should be displayed in descending order of points.
Input1-The first line contains a single integer N, denoting the total no. of matches played.
The following N lines contain outcomes of N matches. The team name may contain spaces.
6
CSK;RR;loss
RR;DD;draw
MI;KKR;win
KKR;RR;loss
CSK;DD;draw
MI;DD;draw
Output1- If there are no teams to print in summary, print "No Output". Constraints
Names of teams may contain spaces but will be less than 24 characters 100 >= N >= 0.
Team: RR, Matches Played: 3, Won: 2, Lost: 0, Draw: 1, Points: 7
Team: MI, Matches Played: 2, Won: 1, Lost: 0, Draw: 1, Points: 4
Team: DD, Matches Played: 3, Won: 0, Lost: 0, Draw: 3, Points: 3
Team: CSK, Matches Played: 2, Won: 0, Lost: 1, Draw: 1, Points: 1
Team: KKR, Matches Played: 2, Won: 0, Lost: 2, Draw: 0, Points: 0Given a student has scored
M marks in Maths, P marks in Physics and C marks in Chemistry. Write a program to check if a student is eligible for admission in a professional course based on the following criteria:Sum of marks in any two subjects >= 100 and M + P + C >= 180.
The first line is an integer
The output should be a single line containing
Given
M = 82, P = 55, C = 45.
M + P >= 100,(137 >= 100)
M + C >= 100,(127 >= 100)
and, M + P + C >= 180 (82 + 55 + 45 >= 180)
So, the output should be
True.
Sample Input 1
82
55
45
Sample Output 1
True
Sample Input 2
71
30
70
Sample Output 2
False
Numbers in String - 2
Given a string, write a program to return the sum and average of the 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 numbers that appear in the string. Note: Round the average value to two decimal places.
input1-I am 25 years and 10 months old
output1-35
17.5input2-1time3 %times4
output2-8
2.67Numbers 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.input1-I am 25 years and 10 months old
output1-8
2.0input2-Anjali25 is python4 Expert
output2-11
3.67Smallest Missing Number
Given a list of numbers, write a program to print the smallest positive integer missing in the given numbers. Input-The input will be a single line containing numbers separated by space. Output-The output should be a single line containing the smallest missing number from given numbers.
input-1: 3 1 2 5 3 7 7
output-1:4
input-2: 5 5 2 3 1 8 8 4
output-2:6
Not getting proper output
Tic-Tac-Toe game
Abhinav and Anjali are playing the Tic-Tac-Toe game. Tic-Tac-Toe is a game played on a grid that's three squares by three squares. Abhinav is O, and Anjali is X. Players take turns putting their marks in empty squares. The first player to get 3 of her marks in a diagonal or horizontal, or vertical row is the winner. When all nine squares are complete, the game is over. If no player has three marks in a row, the game ends in a tie. Write a program to decide the winner in the Tic Tac-Toe game.
Not getting output please send corrected output
Add two polynomials
Given two polynomials A and B, write a program that adds the given two polynomials A and B.
Input
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.