Property Painting Coding Question

Property Painting Coding Question

TCS Coding Question Day 2 Slot 1 : Question 1

 

This question has been asked in the TCS NQT 2020 Day 2 Slot 1

Topic : Conditional Statement

Time Given : 15 Minutes

Difficulty : 2/5 stars

We want to estimate the cost of painting a property. Interior wall painting cost is Rs.18 per sq.ft. and exterior wall painting cost is Rs.12 per sq.ft.

Take input as
1. Number of Interior walls
2. Number of Exterior walls
3. Surface Area of each Interior 4. Wall in units of square feet
Surface Area of each Exterior Wall in units of square feet

If a user enters zero  as the number of walls then skip Surface area values as User may don’t  want to paint that wall.

Calculate and display the total cost of painting the property
Example 1:

6
3
12.3
15.2
12.3
15.2
12.3
15.2
10.10
10.10
10.00
Total estimated Cost : 1847.4 INR

Note: Follow in input and output format as given in above example

Day 2 Slot 1 Question 2

Click on the below button to study Day 2 Slot 2 Question 1 of TCS NQT Coding 2020 exam

Code

TCS Coding Questions

Click on the below button to study more TCS Coding Question

TCS Coding Question

3 comments on “Property Painting Coding Question”


  • 21mmc027

    n_interior_walls=int(input())
    n_exterior_walls=int(input())
    s=s1=0
    for i in range(n_interior_walls+n_exterior_walls):
    if i<n_interior_walls:
    s+=float(input())
    else:
    s1+=float(input())
    tot_est_cost=18*(s)+12.*(s1)
    print(tot_est_cost)


  • Yash

    int_wall=int(input())
    ext_wall=int(input())
    iwall=[]
    ewall=[]
    for i in range(int_wall):
    iwall.append(float(input()))
    for i in range(ext_wall):
    ewall.append(float(input()))
    isum=sum(iwall)*18
    esum=sum(ewall)*12
    print(“Total estimated cost: {}”.format(isum+esum))


  • MAYANK

    interior_walls = []
    exterior_walls = []

    a = int(input(‘Enter the number of interior walls : ‘))
    b = int(input(‘Enter the number of exterior walls : ‘))

    for i in range(a):
    interior_walls.append(float(input(‘Surface area of interior walls : ‘)))

    for i in range(b):
    exterior_walls.append(float(input(‘Surface area of exterior walls : ‘)))

    print(interior_walls)
    print(exterior_walls)

    sum1 =0
    sum2 =0

    for i in interior_walls:
    sum1 = sum1 + i
    i +=1

    for i in exterior_walls:
    sum2 +=i
    i+=1

    if a<0 or b<0:
    print('Invalid Input')
    exit()

    if a and b :
    print('Total cost to paint both the walls are ', (sum1*18 + sum2*12),"INR")

    else:
    if a :
    print('Cost to paint interior walls are ', sum1*18,"INR")
    elif b:
    print('Cost to paint exterior walls are ', sum2*12,"INR")
    else:
    print('Toatka cost estimated 0.0 INR')