input_output/quickref.tex
changeset 329 5c8e88276e1f
parent 236 33828497b5da
equal deleted inserted replaced
328:9ab73cbdd5a8 329:5c8e88276e1f
     1 Creating a tuple:\\
     1 Printing a variable:\\
     2 {\ex \lstinline|    t = (1, "hello", 2.5)|}
     2 {\ex \lstinline|    print x|}
     3 
     3 
     4 Accessing elements of tuples:\\
     4 Printing with out a new line:\\
     5 {\ex \lstinline|    t[index] Ex: t[2]|}
     5 {\ex \lstinline|    print x, |}
     6 
     6 
     7 Accessing slices of tuples:\\
     7 Using modifiers while printing:\\
     8 {\ex \lstinline|    t[start:stop:step]|}
     8 {\ex \lstinline|    print "a is \%d b is \%f"\%(a, b)|}
     9 
     9 
    10 Swapping values:\\
    10 Taking input from user:\\
    11 {\ex \lstinline|    a, b = b, a|}
    11 {\ex \lstinline|    x = raw_input()|}
       
    12 
       
    13 Display a prompt while taking input:\\
       
    14 {\ex \lstinline|    x = raw_input("Type a number: ")|}
       
    15