Posts

Showing posts from August, 2020

Basic Operations on Data using NumPy

  FLATTENING TO THE DATAFRAME Flattening of the Dataframe   Ankit is going to  manage the event data . He is having the data as dataframe, and his manager wants to print those customers name who booked the event in the same month.  But the manager wants to print in the array format. So help Ankit to print customers name whose event month is same. And flatten the data and print in the array (list) format. The following is the 2D format for the dataframe:     customer_name, address, date, eventType, cost, noOfPeople Here eventType is described as marriage, get together, and mehndi.    Filled the data in the dataframe as the CSV file, in the above format. Input Format: For a sample dataframe, see the attached  CSV  file. Output Format: The output is the list of customers name with the month number of event booking. Sample Input: See the attached CSV file. Sample Output:   Flatten Data: ['Vikram' '02' 'Amit' '02'] Description of th...

Pyhton - ONE TO ONE RELATIONSHIP

  P11 / ONE TO ONE RELATIONSHIP – 2 P11 / One to One Relationship – 2   Create a class named  Address  with the following private_attributes __street __city __state   Include a constructor __init__(self, street, city, state)   Include a method __str__(self) This method returns a string corresponding to Address details in the format specified in the sample output.   Include @property decorator for state   Create a class named  Person  with the following private_attributes __name __age __address (of type Address)   Include a constructor __init__(self, name, age, address)   Include a method __str__(self) This method returns a string corresponding to Person details in the format specified in the sample output.   Include @property decorator for name   Include @property decorator for address   Create objects of the above classes and test them.   Input and Output Format: Refer Sample Input and Output for formatting...

Python Functions and Recursion

  S6P10-WATER CHALLENGE Water Challenge   ""Kids on the Move" is a challenging game show organized for kids from age 10 to 15 years. Eddy and Sarah participated at the show and progressed to the semi-finals. At the semi-finals, they were given two vessels, one of which can accommodate a litres of water and the other - b litres of water. The challenge to them was to determine the number of steps required to obtain exactly c litres of water in one of the vessels.   At the beginning both vessels are empty. The following operations are counted as 'steps': emptying a vessel, filling a vessel, pouring water from one vessel to the other, without spilling, until one of the vessels is either full or empty. Help the kids clear the challenge and progress to the finals. Write a recursive function to find the number of steps required to obtain exactly c litres of water in one of the vessels.   C Function Specifications: Use the function name, return type and the argument type...

Python Modules and Packages, Date and Time Functions, File Handling

Image
  SUM OF THE INTEGERS IN THE FILE_PY  Sum of the Integers in the file Consider an input file "sample.txt" with integer values. Write a program to open the file and read the content to find the sum of all values in the file. Rule: The file name should be sample.txt. Input format: Give the input as a file which contains the integer values. Output format: The output will be the integer which is the sum of the integers. Display the output in the console. Sample Input file ( sample.txt) : 1 2 3 4 5 Sample Output: The sum of the integers in the file sample.txt is:15 NUMBER OF LINES IN THE FILE Number Of Lines in the file Write the program to open an input file and read the number of lines in the input file. Input format: Input is a file. Filename:  input.txt Output format: The output will be the integer which is the number of lines in the file. Display the output in the console. Sample Input file (input.txt): C was invented to write an operating system called UNIX. C is a ...