Posts

S-1

  18.1.2.   Understanding If construct 02:40 The general syntax of if statement in  Python  is, If test expression:   statement(s) The  if-construct  is a selective construct. The statements within the if block are executed only once when the condition evaluates to True. Otherwise, the control goes to the first statement after the if-construct. In  Python , the body (block of statements) of the If statement is indicated by indentation and the first unindented line marks the end. Python  interprets  non-zero values  as  True .  None  and  0  are interpreted as  False . Here is a simple program to illustrate the simple  if-statement : if (12 % 2 == 0): print("12 is divisible by 2") # Notice the Indentation print("Execution done") Write a program to check whether the given integer is divisible by 3 or not, and print the result to the console as shown in the examples. Sample Input and Output 1...

CONVERTING TUPLE INTO LIST AND LIST INTO TUPLE

  mytuple = ( "i" , "love" , "python" ) list1=list(mytuple) #Write the missing code here print( "Given Tuple:" ,mytuple) print( "After Converting Tuple into List:" ,list1) list1[ 1 ]= "practice" print( "List after changing element:" ,list1) tuple1=tuple(list1) print( "After Converting List into Tuple:" ,tuple1) OUTPUT: Test case 1 Given · Tuple: · ('i', · 'love', · 'python') ⏎ After · Converting · Tuple · into · List: · ['i', · 'love', · 'python'] ⏎ List · after · changing · element: · ['i', · 'practice', · 'python'] ⏎ After · Converting · List · into · Tuple: · ('i', · 'practice', · 'python') ⏎