0% found this document useful (0 votes)
14 views15 pages

Week3 240801095

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views15 pages

Week3 240801095

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Week:03-01

Q1) Problem Statement:


Write a program to read two integer values and print true if both the numbers end with the same
digit, otherwise print false.

Example: II 698 and 768 are given, program should print true as they both end with 8.

Sample Input 1
25 53

Sample Output 1
false

Sample Input 2
27 77

Sample Output 2
true

Q2) Problem Statement:


In this challenge, we're getting started with conditional statements.

Task
Given an integer, n, perform the following conditional actions:
If n is odd, print Weird

If n is even and in the inclusive range of 2 to 5, print Not Weird

If n is even and in the inclusive range of 6 to 20, print Weird

If n is even and greater than 20, print Not Weird

Complete the stub code provided in your editor to print whether or not n is weird.

Input Format
A single line containing a positive integer, n.

Constraints

1<n<100

Output Format
Print Weird if the number is weird; otherwise, print Not Weird.

Sample Input 0
3

Sample Output 0
Weird
OUTPUT:

Q3) Problem Statement:


Three numbers form a Pythagorean triple if the sum of squares of two numbers is equal to the
square of the third.

For example, 3, 5 and 4 form a Pythagorean triple, since 3*3+4*4=25=6*5


You are given three integers, a, b, and e. They need not be given in increasing order. If they form a
Pythagorean triple, then print "yes", otherwise, print "no". Please note that the output message is
in small letters.

Sample Input 1
3

Sample Output 1
Yes
OUTPUT:
Week:03-02

Q1) Problem Statement:


Write a program that determines the name of a shape from its number of sides. Read the number
of sides from the user and then report the appropriate name as part of a meaningful message. Your
program should support shapes with anywhere from 3 up to (and including) 10 sides. If a number of
sides outside of this range is entered then your program should display an appropriate error
message.

Sample Input 1
3

Sample Output 1
Triangle

Sample Input 2
7

Sample Output 2
Heptagon

Sample Input 3
11

Sample Output 3
The number of sides is not supported.
OUTPUT:

Q2) Problem Statement:


The Chinese zodiac assigns animals to years in a 12-year cycle. One 12-year cycle is shown in the
table below. The pattern repeats from there, with 2012 being another year of the Dragon, and 1999
being another year of the Hare.

Year Animal

2000 Dragon

2001 Snake

2002 Horne

2003 Sheep

2004 Monkey

2005 Rooster

2006 Dog

2007 Pig

2008 Rat
2009 Ox
2010 Tiger

2011 Hare

Write a program that reads a year from the user and displays the animal associated with that year.
Your program should work correctly for any year greater than or equal to zero, not just the ones
listed in the table.

Sample Input 1
2004

Sample Output 1
Monkey

Sample Input 2
2010

Sample Output 2
Tiger

OUTPUT:
Q3) Problem Statement:
Positions on a chess board are identified by a letter and a number. The letter identifies the
column, while the number identifies the row,
Write a program that reads a position from the user. Use an if statement to determine if the
column begins with a black square or a white square. Then use modular arithmetic to report the
color of the square in that row. For example, if the user enters al then your program should report
that the
square is black. If the user enters d5 then your program should report that the square is white. Your
program may assume that a valid position will always be entered. It does not need to perform any
error checking.

Sample Input 1
A1

Sample Output 1
The square is black.

Sample Input 2
D5

Sample Output 2
The square is white.
OUTPUT:
Week:03-03

Q1) Problem Statement:


Some data sets specify dates using the year and day of year rather than the year, month, and day of
month. The day of year (DOY) is the sequential day number starting with day 1 on January 1st.

There are two calendars - one for normal years with 365 days, and one for leap years with 366 days.
Leap years are divisible by 4. Centuries, Cent like 1900, are not leap years unless they are divisible by
400. So, 2000 was a leap year.

To find the day of year number for a standard date, scan down the Jan column to find the day of
month, then scan across to the appropriate month column and read the day of year number.
Reverse the process to find the standard date for a given day of year. Write a program to print the
Day of Year of a given date, month and year

Sample Input 1
18

2020

Sample Output 1
170
OUTPUT:

Q2) Problem Statement:


Suppandi is trying to take pan in the local village math qua. In the first round, he is asked about
shapes and areas. Suppandi, is confused, he was never any good at math. And also, he is bad at
remembering the names of shapes. Instead, you will I be helping him calculate the area of shapes.

 When he says rectangle, he is actually referring to a square.


 When he says square, he is actually referring to a triangle.
 When he says triangle, he is referring to a rectangle
 And when he is confused, he just says something random. At this point, all you can do
is say 0.
 Help Suppandi by printing the correct answer in an integer.

Input Format
 Name of shape (always in upper case R -> Rectangle, S--> Square, T->Triangle)
 Length of 1 side
 Length of other side

Note: In case of triangle, you can consider the sides as height and length of base
Output Format
 Print the area of the shape.
Sample Input 1
T 10

20

Sample Output 1

200
OUTPUT:

Q3) Problem Statement:


superday he arrives there. They to his home planet. It is very important for him to know which dy
week with the fou. They don't follow a 10-day following days: hitney follow

Day Number Name of Day


1 sunday
2 monday
3 tuesday
4 wednesday
5 thursday
6 friday
7 Saturday
8 kryptoday
9 coluday
10 daxamday

Here are the rules of the calendar:


 The calendar starts with Sunday always.
 It has only 296 days. After the 296th day, it goes back to Sunday.
You begin your journey on a Sunday and will reach after n. You have to tell on which day you will
arrive when you reach there.

Input format:
Contain a number n (0 <n)

Output format:
Print the name of the day you are arriving on

Sample Input
7

Sample Output
Kryptonday

Sample Input
1

Sample Output
Monday

OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy