Ticker

6/recent/ticker-posts

Python TCS IRA 10th january SBQ -2022

 HELLO DORAEMONS,

IN THIS BLOGPOST ,I HAVE SHARED THE RECENTLY ASKED PYTHON QUESTION AND SOLUTION WHICH IS CERTAINLY USEFUL WHEN YOU WANT TO PRACTICE.HOPE THIS BLOG IS USEFUL TO YOU

Define a class Course having the following

attributes:

*Course name of type String

*Instructor name of type String

*Price of type Float

*Names of subjects in the Course of type List

strings

*Start Date of Course of type String in format

dd/mm/yyyy

*Course type of type string with values as 'Online'

or 'Offline'.

Note:

Define the ___init__ method to initialize the

attributes of the objects to be created.

Create another class Bootcamp with following

attributes:

A List of Course Objects

A Dictionary with instructor name as key and

rating as Value.

Create below functions inside the Bootcamp class.


1. This method takes the course type and price as

input parameters. It searches for the given type

of course, having price less than the given input

price with the instructor rating >  6. Create a dictionary of

these courses with the course name as key and price

as the value. Sort the courses based on the price

value in ascending order. Return the dictionary to the

main method. If no Course fulfilling the conditions

mentioned is found then the method should return

None.


2. This function takes the year of Course (as number)

as input parameter. It returns total Amount for all

online courses from the list of courses of the

Bootcamp class where year from the start date of

Course matches with the passed argument and any

one of the subject names in the subject List attribute

matches "Python". If no Course fulfilling the

conditions mentioned is found, then the method

should return None.


Note: All string comparisons should be case

insensitive.


Instructions to write main section of the code:

a. You would require to write the main section

completely, hence please follow the below

instructions for the same.

b. You would require to write the main program which

is inline to the "sample input description section

mentioned below and to read the data in the same

sequence.

c. Create the respective objects (Course and

Bootcamp) with the given sequence of arguments to

fulfill the init method requirement defined in the

respective classes referring to the below instructions.

1. Create a list of course objects. To create the list,


a . Read a number for the count of course objects to be created and added to the list .. 


b . Create a Course object after reading the data related to it and add the object to the list of Course objects ( pls check the below point ' c ' for Names of subjects ) . This point repeats for the number of Course objects ( considered in the first line of input ) point # c.l.a . c . For creating the list of subjects , 


1. Read a number for the count of subjects in the Course , 


2. Read the value for subject name and add it to the list of subjects . This point will repeat for the number of subjects taken in above point ( 1 ) . 


d . Create a dictionary of 3 items . To create the dictionary , 


I. Read instructor name as the key of the dictionary 


ii . Read rating of the instructor as the value for the dictionary 


point i ) and ii ) above will be repeated 3 times . 


e . Read a string depicting the type of course to be provided as argument to the first function described above

f . Read a float value depicting the price of the Course to be provided as argument to the first function described above

g . Read an integer value as input depicting  year to be provided as argument to the second function described above .

h . call the methods described above from the main section with appropriate values as arguments from the main section 


1. Display the course name and the price for the courses in the dictionary returned by the first function . You may refer to the sample output for the display format . If function returns None , then display the message ' No course found with given criteria ' ( excluding the quotes ) . 1. Display the total price returned by the second function . You may refer to the sample output for the display format . If None is returned by the function , then display the message ' No course available with given criteria ' ( excluding the quotes ) . 


You can use / refer the below given sample input and output to verify your solution using Test against Custom Input option in HackerRank 


Input Format for Custom Testing 


a . The 1st input taken in the main section is the number of Course objects to be added to the list of Course , say x .

b . The next line of input is the name of the Course . 

c . Next input denotes the instructor of the Course .

d . The next input denotes the price of the course . 

e. Next line of input denotes number of subjects present in the course , say ' n ' 

f . Next n lines of inputs are the subject names taken one after the other .

g . Next set of inputs are the start date of Course and type of the Course ( " online " or " offline " ) .



Point b to g is repeated for x times ( where x is the number of Course objects given in the first line of input ) 


h . The next 6 lines of input are the key ( instructor name ) and value ( instructor rating ) provided for the instructor rating dictionary of 3 items .

I. The next 2 lines of input refers the type of course and price to be passed as argument to the first function , 


j. The next line of input refers the year to be passed as argument to the second function .. 


You can consider below sample input and output to verify your implementation before submitting in Hackerrank . 


Sample Input 1 :

 

4

Intro to Programming 

John

550

2

Python

Java

02/10/2021

online

Web Development Basics

Tim 

999.9

3

HTML 

CSS 

JavaScript 

11/11/2021 

offline

Back - end Development 

John

899

3

Python

Flask

Django

07/07/2021 

online

Machine Learning 

Andrew

749

3

Python

Keras

Tensorflow

09/04/2020 

online

John

8

Tim

7

Andrew

9

online

900

2021


Output : 


Intro to Programming 550.0

Machine Learning 749.0 

Back - end Development 899.0 

1449.0


Sample Input2:


4

Intro to Programming

John

550

2

Python

Java

02/10/2021

online 

Web Development Basics

Tim

999.9

3

HTML

CSS

JavaScript

11/11/2021

offline

Back - end Development

John

899 

3

Python

Flask

Django

07/07/2021

online

Machine Learning

Andrew

749 

3

Python

Keras

Tensorflow 

09/04/2020

online

John

8

Tim

7

Andrew

9

offline

1200

2019 


Output : 


Web Development Basies 999.9 

No course available with given criteria


SOLUTION VIDEO FOR THIS QUESTION:

HOPE THIS IS HELPFUL TO YOU GUYS.IF YOU LIKE MY WORK ,CONSIDER SUBSCRIBING TO MY CHANNEL AND FOLLOW MY BLOGPOST FOR MORE UPDATES

Post a Comment

0 Comments