PYTHON AND HADOOP BASICS: PROGRAMMING FOR BEGINNERS - 2 BOOKS IN 1 - Learn Coding Fast! PYTHON AND HADOOP Crash Course, A QuickStart Guide, Tutorial Book by Program Examples, In Easy Steps! by TAM SEL & J KING

PYTHON AND HADOOP BASICS: PROGRAMMING FOR BEGINNERS - 2 BOOKS IN 1 - Learn Coding Fast! PYTHON AND HADOOP Crash Course, A QuickStart Guide, Tutorial Book by Program Examples, In Easy Steps! by TAM SEL & J KING

Author:TAM SEL & J KING [SEL, TAM]
Language: eng
Format: azw3
Published: 2020-07-10T16:00:00+00:00


print (r 'C://python37' ) # prints C://python37 as it is written

print ( "The string str : %s" %(str)) # prints The string str : Hello

Output:

HelloHelloHello

Hello world

o

ll

False

False

C://python37

The string str : Hello

Python Tuple

Python Tuple is used to store unchanged Python object set. The tuple is similar to lists since it is possible to adjust the value of the items stored in the array, whereas the tuple is immutable and it is not possible to alter the value of the items stored in the tuple.

A tuple can be written as a collection of comma-separated(,) values accompanied by the small() brackets. The parentheses are optional but use of them is good practice. They may describe a tuple as follows.

T1 = ( 101 , "Peter" , 22 )

T2 = ( "Apple" , "Banana" , "Orange" )

T3 = 10 , 20 , 30 , 40 , 50

print(type(T1))

print(type(T2))

print(type(T3))

Output:

<class 'tuple'>

<class 'tuple'>

<class 'tuple'>

A tuple is indexed as is the case for the lists. You can view the items in tuple using their unique index value.

Example - 1

tuple1 = ( 1 0 , 2 0 , 3 0 , 4 0 , 5 0 , 6 0 )

print(tuple1)

count = 0

fo r i in tuple1:

print ( "tuple1[%d] = %d " %(count, i))

count = count + 1

Output:

(10, 20, 30, 40, 50, 60)

tuple1[0] = 10

tuple1[1] = 20

tuple1[2] = 30

tuple1[3] = 40

tuple1[4] = 50

tuple1[5] = 60

Example - 2

tuple1 = tuple(input( "Enter the tuple elements ... " ))

print(tuple1)

count = 0

fo r i in tuple1:

print( "tuple1[%d] = %s " %(count, i))

count = count+ 1

Output :

Enter the tuple elements ...123456

('1', '2', '3', '4', '5', '6')

tuple1[0] = 1

tuple1[1] = 2

tuple1[2] = 3

tuple1[3] = 4

tuple1[4] = 5

tuple1[5] = 6



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.