Pythonic has Published 18 Articles

How to print a string two times with single statement in Python?

Pythonic

Pythonic

Updated on 30-Jul-2019 22:30:20

219 Views

When used with strings, asterisk (*) is defined as repetition operator. It concatenates given string as many times as number followed by asterisk. >>> string = 'abcdefghij' >>> print (string*2) abcdefghijabcdefghij

How to print concatenated string in Python?

Pythonic

Pythonic

Updated on 30-Jul-2019 22:30:20

403 Views

When used with strings, plus (+) is defined as concatenation operator. It appends second string to the first string. >>> s1 = 'TutorialsPoint ' >>> s2 = 'Hyderabad' >>> print (s1+s2) TutorialsPoint Hyderabad

How to change any data type into a string in Python?

Pythonic

Pythonic

Updated on 30-Jul-2019 22:30:20

209 Views

Any built-in data type converted into its string representation by str() function >>> str(10) '10' >>> str(11.11) '11.11' >>> str(3+4j) '(3+4j)' >>> str([1, 2, 3]) '[1, 2, 3]' >>> str((1, 2, 3)) '(1, 2, 3)' >>> str({1:11, 2:22, 3:33}) '{1: 11, 2: 22, 3: 33}' For a user ... Read More

How you will create your first program in Python?

Pythonic

Pythonic

Updated on 30-Jul-2019 22:30:20

140 Views

You can use any Python aware editor to write Python script. Standard distribution of Python comes with IDLE module which is an integrated development and learning environment. Start IDLE and open a new file from file menu. In the editor page enter print (“Hello World!”) Save the script ... Read More

How to sort a dictionary in Python by values?

Pythonic

Pythonic

Updated on 30-Jul-2019 22:30:20

2K+ Views

Standard distribution of Python contains collections module. It has definitions of high performance container data types. OrderedDict is a sub class of dictionary which remembers the order of entries added in dictionary object. When iterating over an ordered dictionary, the items are returned in the order their keys were first ... Read More

What is the maximum value of float in Python?

Pythonic

Pythonic

Updated on 30-Jul-2019 22:30:20

760 Views

In sys module, a struct sequence (tuple of named elements) called float_info has been defined. In this structure, an element max returns maximum representable finite float number. >>> import sys >>> sys.float_info.max 1.7976931348623157e+308

What is the maximum length of string in Python?

Pythonic

Pythonic

Updated on 30-Jul-2019 22:30:20

7K+ Views

Maximum length of a string is platform dependent and depends upon address space and/or RAM. The maxsize constant defined in sys module returns 263-1 on 64 bit system. >>> import sys >>> sys.maxsize 9223372036854775807 The largest positive integer supported by the platform's Py_ssize_t type, is ... Read More

What is the maximum size of list in Python?

Pythonic

Pythonic

Updated on 30-Jul-2019 22:30:20

5K+ Views

Maximum length of a list is platform dependent and depends upon address space and/or RAM. The maxsize constant defined in sys module returns 263-1 on 64 bit system. >>> import sys >>> sys.maxsize 9223372036854775807 The largest positive integer supported by the platform's Py_ssize_t type, is ... Read More

Advertisements