Posts

Showing posts with the label Task

Python_Task_Assignment

Python_Task_Assignment Task 1 We have declared a tuple containing five same elements as following: T = (‘python’, ‘python’, ‘python’, ‘python’, ‘python’). Re-write the same code in an optimal/simple way that fetches the same result ?. # Tuple having names my_tuple = ( 'python' , ) * 5 print ( my_tuple )   ('python', 'python', 'python', 'python', 'python') Task 2 Write code to print characters from a string that are present at an even index number. For example, if your input string is "python", the output characters will be (p,t,o). # read a string str = input ( "Enter a string \n " ) # create a string with characters at multiples of 2 modified_string = str [:: 2 ] print ( modified_string ) pto Task 3 Write a function that calculates the average of the elements of the list:elements = [5, 7, 4, 9, 2] elements = [ 5 , 7 , 4 , 9 , 2 ] # using sum() method count = sum ( elements ) # finding average avg = count / len (...