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

AI (33) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (146) C (77) C# (12) C++ (82) Course (67) Coursera (198) Cybersecurity (24) data management (11) Data Science (106) Data Strucures (8) Deep Learning (13) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (21) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (46) Meta (18) MICHIGAN (5) microsoft (4) Nvidia (1) Pandas (3) PHP (20) Projects (29) Python (893) Python Coding Challenge (285) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (42) UX Research (1) web application (8)

Followers

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