Menu

Fashion Trendy
  • Drop Down

    • Abstract
    • Model
    • Techo
    • Options
  • Photography Pictures Product

    Drop Menu

    • Crystal
    • Digital
    • Graphs
    • Settings
  • Menu

    THE HONEST VISIONS

    Header Background

    Header Background
    Header Background Image. Ideal width 1600px with.
    • Home
    • Digital Art
      • Pics
        • SEO 1
        • SEO 2
      • CSS
        • CSS 1
        • CSS 2
        • CSS 3
        • CSS 4
        • CSS 5
      • Jquery
        • Jquery 1
        • Jquery 2
    • Fashion
      • Product 1
        • Sub Item
        • Sub Item
      • Product 2
        • Sub Item
        • Sub Item
    • Photography
    • Design
    Go
    Home » TCS PA » TCS python Proctored Assessment 25th January solution

    TCS python Proctored Assessment 25th January solution


    Coding Question 1-

    Create a function check_prime() that takes a number as an argument and returns 1 if the number is prime, 0 if it composite and -1 otherwise

    Create another function print_list() that takes a list of numbers as input.

    • Check_prime(l[1]) and print above conditions as output
    • It uses check_prime() and creates a separate list of prime numbers and composite numbers.
    • It returns the third list containing both the above lists.

    Input-
    count = 5
    list of elements : 1 6 2 4 5

    Output-
    0
    [[2, 5],[1, 6, 4]]

    Solution-

    def print_list(l):
    prime = []
    composite = []
    result = []
    for i in l:
    if check_prime(i) == 1:
    prime.append(i)
    elif (check_prime(i) == 0):
    composite.append(i)
    result.append(prime)
    result.append(composite)
    return result


    if __name__ == "__main__":
    count = int(input())
    l = list(map(int, input().split()))
    print(check_prime(l[1]))
    print(print_list(l))

    Coding Question 2-

    Create a Class Item and initialize attributes as
    -> item_id (int)
    -> item_name (String)
    -> item_price (int)
    -> quantity_available (int)

    Create a method calculate_price() that takes a number quantity as an argument
    -> Check if the quantity is greater than or equal to quantity_availabe or not.
    -> If available, return price as quantity*item_price otherwise return 0.

    Create one more Class Store which takes a list as parameters.
    -> Initialize an attribute item_list that takes list of item objects.
    -> Create a method generate_bill() that takes input as a dictionary (item_name : quantity).
    -> It returns the total price of the items available in the dictionary by using the method calculate_price() in the Item Class

    Input-

    3
    1
    milk
    70
    7
    2
    bread
    50
    5
    3
    jam
    60
    2
    2
    bread
    3
    jam
    1

    Output-

    140
    210

    Solution-

    class Item:
    def __init__(self, a, b, c, d):
    self.id = a
    self.name = b
    self.price = c
    self.quant = d

    def calc_price(self, n):
    if self.quant >= n:
    return self.price * n
    else:
    return 0


    class Store:
    def __init__(self, l):
    self.list = l

    def generate_bill(self, d):
    s = 0
    for a, b in d.items():
    for i in range(len(self.list)):
    if self.list[i].name == a:
    s += self.list[i].calc_price(b)
    return s


    if __name__ == '__main__':
    count = int(input())
    l = []
    for i in range(count):
    id = int(input())
    name = input()
    price = int(input())
    quant = int(input())
    itm = Item(id, name, price, quant)
    l.append(itm)

    s = Store(l)
    d = {}
    num = int(input())
    for i in range(num):
    iname = input()
    quant = int(input())
    d[iname] = quant

    print(l[0].calc_price(2))
    print(s.generate_bill(d))
    theinfinitevisions
    Add Comment
    TCS PA
    Thursday, August 20, 2020

    facebook

    twitter

    google+

    fb share

    About theinfinitevisions

    Related Posts
    < Previous Post Next Post >

    Powered by Blogger.

    Comments

    3-comments

    Comments

    FOLLOW ME

    LATEST

    3-latest-65px

    Facebook


    Top Links Menu

    • 9096307522
    • adarsh8794@gmail.com

    Report Abuse

    Top Links Menu

    • Instagram
    • YouTube
    • Facebook
    • Twitter

    Why did the Chinese soldiers cry before going to the Indo-China border

    Why did the Chinese soldiers cry before going to the Indo-China border? Read on Seeing the power of Indian troops on the Indo-China border, ...

    Menu based on Icons

    • Home
    • catagories
    • Item
    • Item
    • Contact us

    Total Pageviews

    Sections


    Campus

    Courses

    Testimonials

    Blog Archive

    • ▼  2020 (28)
      • ►  September (10)
      • ▼  August (18)
        • All About Former President of India Pranab Mukherjee
        • All about Chadwik Aaron Boseman (1976-2020)
        • 5 Amazing and interesting movies to watch in 2020 ...
        • 5 Amazing and interesting movies to watch in 2020 ...
        • 5 Amazing and interesting movies to watch in 2020 ...
        • 5 Amazing websites for watching Hindi movies onlin...
        • 10 amazing facts about Suashant singh rajput you d...
        • 10 Amazing facts about Indian politics you definit...
        • Ganesh Chaturthi one of the greatest event celebr...
        • TCS python Proctored Assessment 10th february solu...
        • TCS python Proctored Assessment 25th January solution
        • 10 amazing websites you definitely don’t know abou...
        • 10 Amazing websites you definitely don't know abo...
        • TCS python Proctored Assessment 15th January sulution
        • 10 Superstitions In India and There scientific rea...
        • Celebrating 74th Independence Day of INDIA...
        • TCS python Proctored assessment 28th December solu...
        • TCS python Proctored Assessment 17th December solu...

    You Tube Videos

    Campus

    4-tag:Campus-500px-mosaic

    Ad Home

    About

    This just a demo text widget, you can use it to create an about text, for example.

    Testimonials

    3-tag:Testimonials-250px-testimonial

    Main Menu

    • About
    • Home
    • Catagories
    • -Item
    • -Item
    • -Superstitions
    • -Social
    • -Movies
    • -Facts
    • -Amazing websites

    Random Posts

    Recent Posts

    Header Ads

    Popular Posts

    • TCS python Proctored Assessment 15th January sulution
    • Celebrating 74th Independence Day of INDIA...
      Independence day-                          Independence day in India is celebrating annually on 15th august i.e on the same day 74 years be...
    • 10 Superstitions In India and There scientific reasons part 1
      1)Lemon & Green Chillies:           Superstition-   This one is the most common one and many of us do it without knowing the reason. No ...
    • TCS python Proctored Assessment 10th february solution
        Coding Question 1- Create a function palindrome_list() that takes a list of strings as an argument. returns the list of strings which are ...

    Logo

    Logo
    Logo Image. Ideal width 300px.

    Section Background

    Section Background
    Background image. Ideal width 1600px with.

    Section Background

    Section Background
    Background image. Ideal width 1600px with.

    Ads block

    Banner 728x90px

    Blogs

    Section Background

    Section Background

    ABOUT

    theinfinitevisions
    View my complete profile

    Contact us-desc:Feel free to contact us at anytime about our courses and tutorials.

    Name

    Email *

    Message *


    Categories

    actors actress adventure Amazing websites America Bangla Black panther Chadwick Boseman cinema Clothing comedy Congress crime cristopher nolan DC Death Defence Minister drama Facts Famous film filmcommunity filmmaker Finance Minister hollywood horror INC India Indira Gandhi instagram Marvel MCU minister Movies netflix politics Pranab Mukherjee president Rajiv Gandhi science fiction Social Soniya Gandhi Stan lee Superstitions TCS PA theatre TV Shows

    Follow Us

    Sponsor

    SEARCH

    FOLLOW ME

    Popular

    • TCS python Proctored Assessment 15th January sulution
    • Celebrating 74th Independence Day of INDIA...
      Independence day-                          Independence day in India is celebrating annually on 15th august i.e on the same day 74 years be...
    • 10 Superstitions In India and There scientific reasons part 1
      1)Lemon & Green Chillies:           Superstition-   This one is the most common one and many of us do it without knowing the reason. No ...

    Social Share

    Weekly Posts

    • TCS python Proctored Assessment 15th January sulution
    • Celebrating 74th Independence Day of INDIA...
      Independence day-                          Independence day in India is celebrating annually on 15th august i.e on the same day 74 years be...
    • 10 Superstitions In India and There scientific reasons part 1
      1)Lemon & Green Chillies:           Superstition-   This one is the most common one and many of us do it without knowing the reason. No ...

    Like us On Facebook

    Labels

    • actors (7)
    • actress (4)
    • adventure (7)
    • Amazing websites (3)
    • America (2)
    • Bangla (1)
    • Black panther (2)
    • Chadwick Boseman (1)
    • cinema (5)
    • Clothing (3)
    • comedy (5)
    • Congress (1)
    • crime (5)
    • cristopher nolan (5)
    • DC (5)
    • Death (2)
    • Defence Minister (1)
    • drama (5)
    • Facts (2)
    • Famous (3)
    • film (6)
    • filmcommunity (6)
    • filmmaker (6)
    • Finance Minister (1)
    • hollywood (5)
    • horror (4)
    • INC (1)
    • India (3)
    • Indira Gandhi (1)
    • instagram (4)
    • Marvel (6)
    • MCU (2)
    • minister (1)
    • Movies (3)
    • netflix (5)
    • politics (1)
    • Pranab Mukherjee (1)
    • president (1)
    • Rajiv Gandhi (1)
    • science fiction (5)
    • Social (6)
    • Soniya Gandhi (1)
    • Stan lee (2)
    • Superstitions (1)
    • TCS PA (7)
    • theatre (5)
    • TV Shows (2)

    Copyright THE HONEST VISIONS 2014 . Template Created by