Skip to main content

AWS DevOps Engineer Online Exam Question

SRE DevOps Engineer Exam

Programming Language you can select any here I've selected as Python 3


Printing Last two digits 

You are given array consists of n integers. Print the last two digits of its array values. 


Given Inputs 

The first line of input contains an integer n, representing the number of elements in the given array. 

The second line of input contains n space separated integers, representing elements of the given array. 

2

25 10 


Expected Output 

Print the last two digits of the product of array values. 

Note that you always need to print two digits.


Constraints 

1<=n<=100

1<=ar[i]

ar[i] is the element of the array 

                ### YOUR TASK ###
                def output(arr):
                    ### Write you code logic here ###
                    
                    product_arr = 1
                    for i in arr:
                        product_arr*=i 
                    print("Product of array:",product_arr)
                    product_arr_str=str(product_arr)
                    return product_arr_str[-2:]
                
                # XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX #
                
                ### ALREADY GIVEN PROGRAM: ###
                
                # Product of given integer array elements 
                # print only last 2 digits of the product
                def convert_int(arr):
                    new_arr = []
                    for item in arr:
                        new_arr.append(int(item))
                    return new_arr
                
                # Input array
                InputArray = []
                n = int(input("Enter the number of elements:"))
                print(n)
                length = 0
                while True:  
                    InputArray = input("Enter Array with n spaces : ").split(' ')
                    print(len(InputArray))
                    if len(InputArray) == n:
                        break
                    else:
                    	print('Invalid , check the number of elements.' )
                        
                InputArray = convert_int(InputArray)
                
                # Call the function output passing InputArray
                print("last two digits of product array : ", output(InputArray))
                
            

Output :

Execution of the above program will be accepting the three numbers if not it will ask again for input..

As per the logic required to be product of 3 members will be displayed and last digits of the product will be displayed.



Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi, I read your whole blog. This is very nice. Good to know about the career in. We are also providing various AWS DevOps Engineer, anyone interested can AWS DevOps Engineer for making their career in this field.

    ReplyDelete

Post a Comment

Popular posts from this blog

Python Sets and Dictionaries

Python Sets Python Maps examples A mapping object maps hashable values to arbitrary objects. Mappings are mutable objects. There is currently only one standard mapping type, the dictionary. Dictionaries consist of pairs (called items) of keys and their corresponding values. Dictionaries can be created by placing a comma-separated list of key: value pairs within curly braces Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples. Python Set Operations and methods Python Set methods continueed >>> SET={'new','old','list','new'} >>> SET set(['new', 'old', 'list']) Lets play with set operations, it is more like school math here... >>> s={1,2,3,4} >>> k={3,4,5,6} >>> len(s) 4 >>> len(k) 4 >>> 1 in s True >>...

Python Interview Questions -Coding Snipets

 This post is dedicated for all DevOps Engineer, Software Engineers who are preparing for Coding Interviews,  Overview of Coding Interviews Most Companies looking for People with minimum Coding knowledge. In a coding interview, you will be given a small problem to solve within 10 - 20 minutes online screen or in-person on their system. In the question, you might be having some part of the code framed and you might be asked to write a snippet of code in between. You need to understand the code comments and proceed to build the expected snippet of code. Bigger companies look for the General purpose questions, where small companies look for specific questions. The General questions would be like this: Determine if the given word is a palindrome or not. (Example madam) Determine given number is prime or not. How to prepare for a coding interview? Now we have the flexibility to choose the programming language on which you are comfortable.  In general DevOps Infra guys will be ...

AWS Auto Scaling using Python Boto3

Auto Scaling Group in AWS configure using Python Boto3  What is Auto Scaling means?  This is key capability or power of Cloud Computing Engineers believe in their skills on scaling abilities.  Amazon EC2 Auto Scaling helps to maintain application availability and lets automatically add or remove EC2 instances using scaling policies that we define.  There are 2 types of scaling policies : Dynamic or predictive. These scaling policies let us add or remove EC2 instances capacity to service established or real-time demand patterns. It contains various steps involved in Auto Scaling process using Python Boto3 we will explore every step that accumulate to form a complete automation solution for a DevOps project. ASG Groups associated with ELB and EC2 instances   Understanding AWS Auto scaling configuration steps Check any running instances Create launch configuration Configure ASG for Auto scaling Verify the configuration Disable Auto Scaling In order to setup A...