Sunday, 26 November 2023

Match the following for the each values !!

 


Answer

tpl1 = ('A',) - Tuple

tpl1 = ('A') - String

t = tpl[::-1] - Sorts tuple

('A', 'B', 'C', 'D') - tuple of strings

[(1, 2), (2, 3), (4, 5)] - list of tuples

tpl = tuple(range(2, 5)) - (2, 3, 4)

([1, 2], [3, 4], [5, 6]) - tuple of lists

t = tuple('Ajooba') - tuple of length 6


Explanation: 

tpl1 = ('A',) - This creates a tuple named tpl1 containing a single element 'A'. Note the comma after 'A', which is essential for creating a tuple with a single element.


tpl1 = ('A') - This actually creates a string, not a tuple. To create a tuple with a single element, you need to include a comma: tpl1 = ('A',).


t = tpl[::-1] - This reverses the order of elements in the tuple tpl. The [::-1] slicing notation is used to reverse the sequence.


('A', 'B', 'C', 'D') - This is a tuple of strings with four elements: 'A', 'B', 'C', and 'D'.


[(1, 2), (2, 3), (4, 5)] - This is a list of tuples, where each tuple contains two integers.


tpl = tuple(range(2, 5)) - This creates a tuple named tpl with elements generated using range(2, 5), resulting in the tuple (2, 3, 4).


([1, 2], [3, 4], [5, 6]) - This is a tuple of lists, where each list contains two integers.


t = tuple('Ajooba') - This creates a tuple named t from the characters of the string 'Ajooba'. The resulting tuple has six elements, one for each character.

0 Comments:

Post a Comment

Popular Posts

Categories

100 Python Programs for Beginner (53) AI (34) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (173) C (77) C# (12) C++ (82) Course (67) Coursera (226) Cybersecurity (24) data management (11) Data Science (128) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (59) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (3) Pandas (4) PHP (20) Projects (29) Python (932) Python Coding Challenge (364) Python Quiz (25) Python Tips (2) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (3) Software (17) SQL (42) UX Research (1) web application (8) Web development (2) web scraping (2)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses