InterviewSolution
Saved Bookmarks
| 1. |
How will you create a set in python? |
|
Answer» A set is created by placing all the elements separated by comma within a pair of curly brackets. The set( ) function can also used to create sets in Python. Syntax: Set Variable = {El, E2, E3 ………………. En} Example: >>> S1={1,2,3, ’A’ ,3.14} >>> print(S1) {1,2, 3, 3.14, ‘A’} >>> S2={1,2,2, ’A’ ,3.14} >>> print(S2) {1,2, ’A’ , 3.14} |
|