#11 Tuple in Python | Python Tutorial

Code For Kids · Beginner ·🛠️ AI Tools & Apps ·4y ago

Key Takeaways

This video tutorial explains the basics of tuples in Python, including how to declare and use them, their characteristics, and various techniques for working with tuples.

Full Transcript

foreign welcome back to my channel code for kids so in our previous video we did the list so today we are going to study about tuples in Python okay so first thing in the list we can add multiple items okay so in the tuples also we can add the multiple items but we have some difference between Tuple and list so we can say Tuple are used to store multiple items in a single variable means in a same variable we can add any number of items so we can say tuples are built-in data type that is used in a python to store a collection of data okay like list so in the list also we are storing the multiple data in the Tuple also we are storing the multiple data is a collection of which is ordered and unchangeable okay so in the list we have a square bracket but in a tuple we have round bracket okay so now we will see the Tuple how we will declare the values in the Tuple okay suppose I have one variable which is ABC in this variable so how you will declare your Tuple with the help of your round bracket now here I am going to add some items like we can add code for kids which is our channel name after that suppose here we have scratch so you can add the second item scratch after that we have next like a python so you can add the python also like python after that how you will print this you need to just write print and your variable name which is ABC now if I will run you will get all three items okay so in this way we can declare our okay in this way we can declare our tuples so what is the error here as you can see here we have a DOT so you need to take a comma not DOT okay so now you will get value in the round bracket code for kids which is our first item then you will get scratch which is our second item that you will get the third item which is python okay so we have some Tuple items so we can say Tupper items are ordered unchangeable and allowed duplicates value in the list also we can take a duplicate value in the Tuple also we can add duplicate value the most important part here double items are indexed so for every item we have some index value the first item has index 0. okay after that the second item index has one so here index numbers start from 0 okay next ordered means what when we say that tuples are ordered it means that the items have a defined order and that order will not change okay so that's a tuple are ordered after that a changeable means what Tuple are unchangeable it means that we cannot change add or remove items after the Tuple has been created okay next allow duplicate means what since Tuple are indexed so we can add duplicate items here so now we will check that how you will add the duplicate values suppose here I want to add one more python so python now if you will run it will give you the output not the error okay it means Pi Tuple are here we can allow the duplicate value next how you will find out how many items we have here like your Tuple length Okay so for that we have Len function so what I will do simple I will copy the code now here you need to use your print length function and then we need to take one more bracket now if you will run so what value you will get so what is the index 4 here we have four items if you will add one more item it will return you the value as 5 okay after that even we can create suppose if you want to create Tuple with one item okay so how you will do that how you will create the Tuple with one item okay now suppose I want to add only one item so my variable name ABC here I want to add ABC value then I want to print print ABC my variable name let's see what will happen if you will run you will get ABC okay but what happen if you will take comma here see now this is your double so if you want only one item so you have to use this comma otherwise you will get your normal value not a tuple value okay understood next we can here we have different types of data types in a tuple it means suppose if you want to create integer Tuple or if you want to create your flow type double or if you want to create your string type couple even you can do that suppose here and apple equals to I want to add the value like 1 comma 2 comma 3 comma 4. even we can add Str Tuple which is so now I will add some string value here so always you have to write string inside your double quote or you can write in a single course also let p u r after that so we have integer we have string now then even we can take float Tuple so here we can add the value like 4.5 comma 1.2 like this so here we will take equals to now how you will print this you need to just write print what is our first variable again print what is our second variable strt then print what is your third variable third one is float T now if you will run this but you will get so what we have error here see okay so we took the wrong variable name okay so always you have to check what you did the mistake okay after that what we have the next yes can you just imagine so suppose if you want how you can access the Tuple items so access means what I will take this example suppose you want only one value or two value so how you will do that means you don't want to print all the values you want to print only one or two values suppose we have this code here we have four items now I want to print my first value my first indexed value so always in a python the tuples start from index 0 Okay so in the index 0 we have code for kids in index 1 we have scratch so what you will get the output you will get scratch not code for kids because the index number of code for kids is zero so if you want you will get you have to write here 0. now if you will run you will get code for kids now we have some negative index also so negative index means what so negative index means we can say start from the end not start from the starting position so here minus 1 refers to the last item like in our example we have python minus 2 refers to the second last item okay so reverse indexing start from -1 annual positive means your starting indexing starts from 0 if you will write minus 1 here so what will happen you will get python if you will write -3 so this is or minus 1 minus 2 minus 3 so you will get scratch okay so this is our index C negative here we have range of indexes so range of index means what here we can specify a range of index by specifying where to start and where to in this sum range your minimum value your maximum value okay so see when we specify the range the written value will be a new Tuple with the specified item suppose I want to give the index number like I want to print one two three value start from 1 end with three so in the one we have scratch so what you will get you will get scratch python okay so in this way we can take the index also okay so this is our Tuple here you can create a tuple you can add some items okay after that here in the Tuple it is allow duplication after that you can find out the length of the Tuple here we have some mixed values also if you want only one item in the topper so you need to give the comma you have to remember this okay after that how you will give the range how you will give your negative values okay after that always the Tuple will start from index number 0 and in we have some negative indexing also so this all are the Tuple methods okay so thank you so much okay so now please like share and subscribe our Channel and press the Bell icon if you want more latest update okay so thank you so much

Original Description

In this video, I have explained about tuples in python and how to use several related techniques to write effective python programs.
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Code For Kids · Code For Kids · 46 of 60

1 #Scratch Tutorial 1 | How to create your own Scratch account #codeforkids #scratch #Game Development
#Scratch Tutorial 1 | How to create your own Scratch account #codeforkids #scratch #Game Development
Code For Kids
2 #Scratch Tutorial 2 ||How to enable Share Button option in Scratch #codeforkids #scratch #game
#Scratch Tutorial 2 ||How to enable Share Button option in Scratch #codeforkids #scratch #game
Code For Kids
3 Fish Moving inside an Ocean 🌊🌊 #codeforkids #scratch 🥰
Fish Moving inside an Ocean 🌊🌊 #codeforkids #scratch 🥰
Code For Kids
4 Scratch Programming | Fish Aquarium game | #codeforkids #scratch #game
Scratch Programming | Fish Aquarium game | #codeforkids #scratch #game
Code For Kids
5 Draw the circle in scratch#codeforkids #scratch #game
Draw the circle in scratch#codeforkids #scratch #game
Code For Kids
6 Draw Circles in Scratch || How do you draw shapes on Scratch? #codeforkids #scratch #game #coding
Draw Circles in Scratch || How do you draw shapes on Scratch? #codeforkids #scratch #game #coding
Code For Kids
7 How to Make a Dino Jump Game in Scratch | Tutorial #codeforkids #scratch #game
How to Make a Dino Jump Game in Scratch | Tutorial #codeforkids #scratch #game
Code For Kids
8 Scratch Tutorial || How to Make a Catch Game in Scratch.|| Scratch Tutorial for absolute beginer
Scratch Tutorial || How to Make a Catch Game in Scratch.|| Scratch Tutorial for absolute beginer
Code For Kids
9 Scratch Tutorial || Day 1
Scratch Tutorial || Day 1
Code For Kids
10 Scratch Tutorial || Day 2  (DJ System , Dance and Story writing)
Scratch Tutorial || Day 2 (DJ System , Dance and Story writing)
Code For Kids
11 How to Make A Maze Game in Scratch 3.0 | Scratch 3.0 Tutorial |Scratch Tutorial for begineer
How to Make A Maze Game in Scratch 3.0 | Scratch 3.0 Tutorial |Scratch Tutorial for begineer
Code For Kids
12 Scratch Tutorial || Day 3
Scratch Tutorial || Day 3
Code For Kids
13 Scratch Tutorial || Day 4
Scratch Tutorial || Day 4
Code For Kids
14 Scratch Tutorial | Cat And Mouse Game | Scratch Tutorial for  Beginner
Scratch Tutorial | Cat And Mouse Game | Scratch Tutorial for Beginner
Code For Kids
15 Scratch Tutorial || Day 5
Scratch Tutorial || Day 5
Code For Kids
16 how to make dress up game on scratch || Scratch Tutorial for Beginner
how to make dress up game on scratch || Scratch Tutorial for Beginner
Code For Kids
17 How to Make a Pong Game in Scratch || Scratch Tutorial for Beginner
How to Make a Pong Game in Scratch || Scratch Tutorial for Beginner
Code For Kids
18 Scratch Tutorial || Day 6(part 1)
Scratch Tutorial || Day 6(part 1)
Code For Kids
19 Scratch Tutorial || Day 6( Part 2)
Scratch Tutorial || Day 6( Part 2)
Code For Kids
20 Scratch Tutorial || Day 7
Scratch Tutorial || Day 7
Code For Kids
21 Scratch Tutorial || Day 8
Scratch Tutorial || Day 8
Code For Kids
22 How to Make Piano Game || Learn to Use Music Extension || Scratch Tutorial || Day 8
How to Make Piano Game || Learn to Use Music Extension || Scratch Tutorial || Day 8
Code For Kids
23 How to Make Piano Game || Learn to Use Music Extension ||Scratch Tutorial for beginner
How to Make Piano Game || Learn to Use Music Extension ||Scratch Tutorial for beginner
Code For Kids
24 Scratch Tutorial || Day 9
Scratch Tutorial || Day 9
Code For Kids
25 Scratch Tutorial || Draw Shapes #shorts #codeforkids #youtubeshorts
Scratch Tutorial || Draw Shapes #shorts #codeforkids #youtubeshorts
Code For Kids
26 Scratch Tutorial |How to Draw Shapes in Scratch #scratch #scratchtutorials #codeforkids
Scratch Tutorial |How to Draw Shapes in Scratch #scratch #scratchtutorials #codeforkids
Code For Kids
27 Day 10|| Scratch Tutorial
Day 10|| Scratch Tutorial
Code For Kids
28 Scratch Tutorial || Archery Tutorial
Scratch Tutorial || Archery Tutorial
Code For Kids
29 #1 || Thunkable  Beginner Tutorial  Platform Overview
#1 || Thunkable Beginner Tutorial Platform Overview
Code For Kids
30 App Development ||Tutorial 2 || how to add button in Thunkable || Thunkable for beginner #codeforkid
App Development ||Tutorial 2 || how to add button in Thunkable || Thunkable for beginner #codeforkid
Code For Kids
31 App Development || Tutorial 3||  Beginner Tip "Change screens with a button click" in Thunkable
App Development || Tutorial 3|| Beginner Tip "Change screens with a button click" in Thunkable
Code For Kids
32 Scratch Tutorial ||
Scratch Tutorial ||
Code For Kids
33 Thunkable Tutorial || Using Camera and Image Recognition components with Thunkable
Thunkable Tutorial || Using Camera and Image Recognition components with Thunkable
Code For Kids
34 Build a Translator App with Thunkable ||Thunkable App Development || Tutorial 5||
Build a Translator App with Thunkable ||Thunkable App Development || Tutorial 5||
Code For Kids
35 Thunkable Beginner Tutorial #6  || Web Viewer|| Redirecting App
Thunkable Beginner Tutorial #6 || Web Viewer|| Redirecting App
Code For Kids
36 #1 World in Python || Python Tutorial || Python Programming || Google Colab
#1 World in Python || Python Tutorial || Python Programming || Google Colab
Code For Kids
37 #2 Python Tutorial for Beginners | User input in Python | Command Line Input | Python Variable
#2 Python Tutorial for Beginners | User input in Python | Command Line Input | Python Variable
Code For Kids
38 #3 Python  Comments | How To Write Comments In Python | Python Tutorial For Beginners |
#3 Python Comments | How To Write Comments In Python | Python Tutorial For Beginners |
Code For Kids
39 #4 Python Tutorial for Beginners | Data Types in Python
#4 Python Tutorial for Beginners | Data Types in Python
Code For Kids
40 #5 Numbers & Typecasting in python | Python Tutorial
#5 Numbers & Typecasting in python | Python Tutorial
Code For Kids
41 #6  Strings Tutorial | How To Use Strings In Python | Python Tutorial | Python Training |
#6 Strings Tutorial | How To Use Strings In Python | Python Tutorial | Python Training |
Code For Kids
42 #7 Slicing And Other Functions In Python | Python Tutorials For Absolute Beginners.
#7 Slicing And Other Functions In Python | Python Tutorials For Absolute Beginners.
Code For Kids
43 #8 Boolean in Python | Python Tutorial for Begniner
#8 Boolean in Python | Python Tutorial for Begniner
Code For Kids
44 #9 Python Tutorial for Beginners | Operators in Python
#9 Python Tutorial for Beginners | Operators in Python
Code For Kids
45 #10  Lists And List Functions | Python Tutorials For Absolute Beginners
#10 Lists And List Functions | Python Tutorials For Absolute Beginners
Code For Kids
#11 Tuple in Python | Python Tutorial
#11 Tuple in Python | Python Tutorial
Code For Kids
47 #12  In Python | Python Sets Tutorial | Python Tutorial for Beginners | #python #pythonprogramming
#12 In Python | Python Sets Tutorial | Python Tutorial for Beginners | #python #pythonprogramming
Code For Kids
48 #13 If Elif Else Statement in Python || Python Tutorial for Beginners |
#13 If Elif Else Statement in Python || Python Tutorial for Beginners |
Code For Kids
49 #14  While Loop in Python ||Python Tutorial for Beginners
#14 While Loop in Python ||Python Tutorial for Beginners
Code For Kids
50 Python Tutorial for addition of 2 numbers #shorts #youtubeshorts #codeforkids #pythonprogramming
Python Tutorial for addition of 2 numbers #shorts #youtubeshorts #codeforkids #pythonprogramming
Code For Kids
51 Python Tutorial for absolute Beginner|| While loop #pythonprogramming #shorts #youtubeshorts
Python Tutorial for absolute Beginner|| While loop #pythonprogramming #shorts #youtubeshorts
Code For Kids
52 Machine learning for the kids with Scratch || Machine Learning for kids ||Day 1
Machine learning for the kids with Scratch || Machine Learning for kids ||Day 1
Code For Kids
53 # Tutorial 1 || Machine Learning for kids | Image Classification example | Girl and boy
# Tutorial 1 || Machine Learning for kids | Image Classification example | Girl and boy
Code For Kids
54 #15 For loop in Python || Python Tutorial for Beginner
#15 For loop in Python || Python Tutorial for Beginner
Code For Kids
55 # Tutorial 2 || Machine Learning for kids | Smart Home Automation | Turn On the Fan
# Tutorial 2 || Machine Learning for kids | Smart Home Automation | Turn On the Fan
Code For Kids
56 #Tutorial 3 || Snapchat Filter in Machine Learning|| Machine Learning for the kids ||
#Tutorial 3 || Snapchat Filter in Machine Learning|| Machine Learning for the kids ||
Code For Kids
57 #Tutorial 4 || Image Identification || Machine Learning for the  kids|| Tiger , Elephant, boy
#Tutorial 4 || Image Identification || Machine Learning for the kids|| Tiger , Elephant, boy
Code For Kids
58 Scratch Tutorial || Apple Catcher Game || Fruit Catcher|| catch game in Scratch
Scratch Tutorial || Apple Catcher Game || Fruit Catcher|| catch game in Scratch
Code For Kids
59 Scratch Tutorial || How to record audio in Scratch || Scratch Tutorial for beginner ||
Scratch Tutorial || How to record audio in Scratch || Scratch Tutorial for beginner ||
Code For Kids
60 Scratch Tutorial || how to translate language in scratch || Scratch tutorial for beginner
Scratch Tutorial || how to translate language in scratch || Scratch tutorial for beginner
Code For Kids

This video tutorial covers the basics of tuples in Python, including declaration, characteristics, indexing, and methods. Viewers will learn how to work with tuples in Python and understand their importance in programming.

Key Takeaways
  1. Declare a tuple using round brackets
  2. Understand tuple characteristics: ordered, unchangeable, and allowing duplicates
  3. Use tuple indexing to access specific items
  4. Use the len() function to find the length of a tuple
  5. Use range of indexes to specify a range of items
💡 Tuples are a fundamental data structure in Python, and understanding how to declare and use them is crucial for effective programming.

Related Reads

📰
Google Gemini Scene Extension Rolls Out Globally for AI Plus, Pro and Ultra Subscribers
Google rolls out Scene Extension globally for AI Plus, Pro, and Ultra subscribers, enhancing their Gemini app experience
Dev.to · Ali Farhat
📰
What Happens to Tutoring When AI Knows Everything?
Explore the impact of AI on tutoring and its surprising effect on the industry's spending
Medium · Startup
📰
The NVIDIA DGX Spark Update That Quietly Uninstalled Its Own Dashboard
NVIDIA DGX Spark's update uninstalls its own dashboard, learn how to navigate this change
Medium · LLM
📰
AI Game Art Is Not Engine-Ready Until You Define the Asset Contract
Learn how to make AI-generated game art engine-ready by defining the asset contract, a crucial step for game developers and artists
Dev.to · FrameSprite
Up next
How to Get Your Brand Cited by ChatGPT, Claude and Gemini
Arvow
Watch →