Computer Science, asked by utkarshsangwan, 5 months ago

Write the output of the following Python program a. Name=’Hello world” Print(type(name)) b. List1=[22,33,44,55,66] Print(list1[-2]) ​

Answers

Answered by qwsuccess
0

The Output of given python program is:

a. <class 'str'>

b. 55

  • name stores the sequence of character "Hello world". So it automatically becomes a variable of string data type. Hence on printing the type (data type) of name, str (string) is printed as output.
  • the variable list1 is a list that stores the values 22,33,44,55,66. Using the print statement the element at index -2 of list1 is to be printed. Now, negative index starts from where the list ends. Hence, -1 will give the last element (66) while -2 gives the second-last element (55)
Similar questions