Python Practice Problems for Beginners

 Python Practice Problems for Beginners


Codechef Python Question Solution

Q1. Valentine is Coming

Valentine's Day is approaching and thus Chef wants to buy some chocolates for someone special.

Chef has a total of X rupees and one chocolate costs Y rupees. What is the maximum number of chocolates Chef can buy?

Input Format

  • First line will contain T, the number of test cases. Then the test cases follow.
  • ach test case contains a single line of input, two integers X,Y - the amount Chef has and the cost of one chocolate respectively.


 Q2. Jenga Night Codechef Python Problem



Python Problem

Chef hosts a party for his birthday. There are N people at the party. All these N people decide to play Jenga.

There are X Jenga tiles available. In one round, all the players pick 1 tile each and place it in the tower.
The game is valid if:

  • All the players have a tile in each round;
  • All the tiles are used at the end.
Given N and X, find whether the game is valid.

Input Formate

  • First line will contain T, the number of test cases. Then the test cases follow
  • Each test case contains a single line of input, containing two space-separated integers N and X representing the number of people at the party and the number of available tiles respectively.
Output Formate

For each test case, output in a single line YES if the game is valid, else output NO.

You may print each character of the string in uppercase or lowercase (for example, the strings YeS, yEs, yes and YES will all be treated as identical).

Python Solution Code




Q3. Good Program Codechef Python Solution



Python Problems 

In computing, the collection of four bits is called a nibble.

Chef defines a program as:

Good, if it takes exactly X nibbles of memory, where XX is a positive integer.
Not Good, otherwise.
Given a program which takes N bits of memory, determine whether it is Good or Not Good.

Input Format
  • First line will contain T, number of test cases. Then the test cases follow.
  • The first and only line of each test case contains a single integer N, the number of bits taken by the program.
Output Format
For each test case, output Good or Not Good in a single line. You may print each character of or Not Good in uppercase or lowercase (for example, GoOd, GOOD, good will be considered identical).

Python Problem Solution



Post a Comment

0 Comments