{"id":9269,"date":"2021-10-01T11:00:26","date_gmt":"2021-10-01T05:30:26","guid":{"rendered":"https:\/\/python-programs.com\/?p=9269"},"modified":"2021-11-22T18:33:27","modified_gmt":"2021-11-22T13:03:27","slug":"python-program-to-create-a-list-of-tuples-with-the-first-element-as-the-number-and-second-element-as-the-square-of-the-number","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-create-a-list-of-tuples-with-the-first-element-as-the-number-and-second-element-as-the-square-of-the-number\/","title":{"rendered":"Python Program to Create a List of Tuples with the First Element as the Number and Second Element as the Square of the Number"},"content":{"rendered":"

Tuples in Python:<\/strong><\/p>\n

Tuples are comma-separated sequences or collections of things. In many aspects, they are identical to lists, except that the elements cannot be modified after they are created. Tuples in Python, unlike lists, are immutable objects. They also employ parentheses rather than square brackets.<\/p>\n

Lists in Python:<\/strong><\/p>\n

A list is exactly what it sounds like: a container for various Python objects such as integers, words, values, and so on. In other programming languages, it is equal to an array. It is denoted with square brackets (and this is one of the attributes that differentiates it from tuples, which are separated by parentheses). It is also mutable, which means it can be changed or altered, as opposed to tuples, which are immutable.<\/p>\n

Given lower limit range and upper limit range the task is to Make a list of Tuples with the first element being the number and the second element being the square of the number.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Enter some random lower limit =5\r\nEnter some random lower limit =13<\/pre>\n

Output:<\/strong><\/p>\n

The list of Tuples are :  [(5, 25), (6, 36), (7, 49), (8, 64), (9, 81), (10, 100), (11, 121), (12, 144), (13, 169)]<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Enter some random lower limit =23\r\nEnter some random lower limit =69<\/pre>\n

Output:<\/strong><\/p>\n

The list of Tuples are :  [(23, 529), (24, 576), (25, 625), (26, 676), (27, 729), (28, 784), (29, 841), (30, 900), (31, 961), \r\n(32, 1024), (33, 1089), (34, 1156), (35, 1225), (36, 1296), (37, 1369), (38, 1444), (39, 1521), (40, 1600), (41, 1681), \r\n(42, 1764), (43, 1849), (44, 1936), (45, 2025), (46, 2116), (47, 2209), (48, 2304), (49, 2401), (50, 2500), (51, 2601),\r\n(52, 2704), (53, 2809), (54, 2916), (55, 3025), (56, 3136), (57, 3249), (58, 3364), (59, 3481), (60, 3600), (61, 3721),\r\n(62, 3844), (63, 3969), (64, 4096), (65, 4225), (66, 4356), (67, 4489), (68, 4624), (69, 4761)]<\/pre>\n

Make a list of Tuples with the first element being the number and the second element being the square of the number in Python<\/h2>\n

There are several ways to create a list of tuples with the first element being the number and the second element being square of the given number some of them are:<\/p>\n