Skip to main content

Posts

Showing posts from March, 2022

Cognizant Coding Questions and Answers 2022 - Question 6

  Cognizant Coding Questions and Answers 2022 Problem Statement – Rhea Pandey’s teacher has asked her to prepare well for the lesson on seasons. When her teacher tells a month, she needs to say the season corresponding to that month. Write a program to solve the above task. Spring – March to May, Summer – June to August, Autumn – September to November and, Winter – December to February. Month should be in the range 1 to 12.  If not the output should be “Invalid month”. Sample Input 1: Enter the month:11 Sample Output 1: Season:Autumn Sample Input 2: Enter the month:13 Sample Output 2: Invalid month   Program : mon=int(input("Enter month : ")) if(mon==12 or mon==1 or mon==2):     print("Season : Winter")   elif(mon==3 or mon==4 or mon==5):     print("Season : Spring") elif(mon==6 or mon==7 or mon==8):     print("Season : Summer")   elif(mon==9 or mon==10 or mon==11...

Cognizant Coding Questions and Answers 2022 - Question 5

  Cognizant Coding Questions and Answers 2022 Problem Statement –   In a theater, there is a discount scheme announced where one gets a 10% discount on the total cost of tickets when there is a bulk booking of more than 20 tickets, and a discount of 2% on the total cost of tickets if a special coupon card is submitted. Develop a program to find the total cost as per the scheme. The cost of the k class ticket is Rs.75 and q class is Rs.150. Refreshments can also be opted by paying an additional of Rs. 50 per member. Hint : k and q and You have to book minimum of 5 tickets and maximum of 40 at a time. If fails display “Minimum of 5 and Maximum of 40 Tickets”.  If circle is given a value other than ‘k’ or ‘q’ the output should be “Invalid Input”. The ticket cost should be printed exactly to two decimal places. Sample Input 1 : Enter the no of ticket : 35 Do you want refreshment : y Do you have coupon code : y Enter the circle : k Sample Output 1 : Tick...

Cognizant Coding Questions and Answers 2022 - Question 4

  Cognizant Coding Questions and Answers 2022 Problem Statement – FOE college wants to recognize the department which has succeeded in getting the maximum number of placements for this academic year. The departments that have participated in the recruitment drive are CSE,ECE, MECH. Help the college find the department getting maximum placements. Check for all the possible output given in the sample snapshot Note :  If any input is negative, the output should be “Input is Invalid”.  If all department has equal number of placements, the output should be “None of the department has got the highest placement”. Sample Input 1: Enter the no of students placed in CSE : 90 Enter the no of students placed in ECE : 45 Enter the no of students placed in MECH : 70 Sample Output 1: Highest placement CSE Sample Input 2: Enter the no of students placed in CSE : 55 Enter the no of students placed in ECE : 85 Enter the no of students placed in MECH : 85 ...

Cognizant Coding Questions and Answers 2022 - Question 3

  Cognizant Coding Questions and Answers 2022 Problem Statement – Ritik wants a magic board, which displays a character for a corresponding number for his science project. Help him to develop such an application. For example  when the digits 65,66,67,68 are entered, the alphabet ABCD are to be displayed. [Assume the number of inputs should be always 4 ] Sample Input 1: Enter the digits: 65 66 67 68 Sample Output 1: 65-A 66-B 67-C 68-D Sample Input 2: Enter the digits: 115 116 101 112 Sample Output 2: 115-s 116-t 101-e 112-p Program : a=int(input("Digit 1 : "))   b=int(input("Digit 2 : "))   c=int(input("Digit 3 : "))   d=int(input("Digit 4 : "))   print(str(a)+"-"+chr(a))   print(str(b)+"-"+chr(b))   print(str(c)+"-"+chr(c))   print(str(d)+"-"+chr(d)) for execution and output so check the video :

Cognizant Coding Questions and Answers 2022 - Question 2

  Cognizant Coding Questions and Answers 2022 Problem Statement – Vohra went to a movie with his friends in a Wave theatre and during  break time he bought pizzas, puffs and cool drinks. Consider   the following prices :  Rs.100/pizza Rs.20/puffs Rs.10/cooldrink Generate a bill for What Vohra has bought.   Sample Input 1: Enter the no of pizzas bought : 10 Enter the no of puffs bought : 12 Enter the no of cool drinks bought : 5   Sample Output 1: Bill Details No of pizzas : 10 No of puffs : 12 No of cooldrinks : 5 Total price = 1290 ENJOY THE SHOW!!!   Program : pizza_count=int(input('Enter the no of pizzas bought : '))   puffs_count=int(input("Enter the no of puffs bought : "))   drinks_count=int(input("Enter the no of cool drinks bought : "))   bill=pizza_count*100 + puffs_count*20 + drinks_count*10   print("\n-----------------Bill details------------------")   ...

Cognizant Coding Questions and Answers 2022 - Question 1

  Cognizant Coding Questions and Answers 2022 Problem Statement – Write a program to calculate the fuel consumption of your truck.The program should ask the user to enter the quantity of diesel to fill up the tank and the distance covered till the tank goes dry.Calculate the fuel consumption and display it in the format (liters per 100 kilometers). Convert the same result to the U.S. style of miles per gallon and display the result. If the quantity or distance is zero or negative display ” is an Invalid Input”. [ Note:  The US approach of fuel consumption calculation (distance / fuel) is the inverse of the European approach (fuel / distance ). Also note that 1 kilometer is 0.6214 miles, and 1 liter is 0.2642 gallons.] The result should be with two decimal place.To get two decimal place refer the below-mentioned print statement : float cost=670.23; System.out.printf(“You need a sum of Rs.%.2f to cover the trip”,cost); Sample Input 1: Enter the no of liter...

Persistent Coding Questions and Answer in 2022 - Question 4

Persistent Coding Questions and Answer in 2022 Problem Statement : Sum is given a rectangular paper having dimension h x w, where h is the height and w is the width. Sam wants to fold the paper so its dimension are h1 x w1 in the minimum number of moves. The paper can only be folded parallel to its edges, and after folding the dimension should be integers. For example, given h =8 and w =4, fold the paper until it is h1,w1 =6,1. Find fold along the long edge 6 units from a side, resulting in a paper that is 6 x 4. Next, fold along the width 2 units from the 4 unit edge to have 6 x 2. Fold along the center of the 2 units edge to achieve a 6 x 111 page in three folds. Function Description Write a function minMoves, which will return an integer value that denotes the minimum number of moves in which the task can be achieved minMoves has the following parameter: h: an integer that denotes the initial height w: an integer that denotes the initial width h1: an in...