#11 Tuple in Python | Python Tutorial
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.
Playlist
Uploads from Code For Kids · Code For Kids · 46 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
▶
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#Scratch Tutorial 1 | How to create your own Scratch account #codeforkids #scratch #Game Development
Code For Kids
#Scratch Tutorial 2 ||How to enable Share Button option in Scratch #codeforkids #scratch #game
Code For Kids
Fish Moving inside an Ocean 🌊🌊 #codeforkids #scratch 🥰
Code For Kids
Scratch Programming | Fish Aquarium game | #codeforkids #scratch #game
Code For Kids
Draw the circle in scratch#codeforkids #scratch #game
Code For Kids
Draw Circles in Scratch || How do you draw shapes on Scratch? #codeforkids #scratch #game #coding
Code For Kids
How to Make a Dino Jump Game in Scratch | Tutorial #codeforkids #scratch #game
Code For Kids
Scratch Tutorial || How to Make a Catch Game in Scratch.|| Scratch Tutorial for absolute beginer
Code For Kids
Scratch Tutorial || Day 1
Code For Kids
Scratch Tutorial || Day 2 (DJ System , Dance and Story writing)
Code For Kids
How to Make A Maze Game in Scratch 3.0 | Scratch 3.0 Tutorial |Scratch Tutorial for begineer
Code For Kids
Scratch Tutorial || Day 3
Code For Kids
Scratch Tutorial || Day 4
Code For Kids
Scratch Tutorial | Cat And Mouse Game | Scratch Tutorial for Beginner
Code For Kids
Scratch Tutorial || Day 5
Code For Kids
how to make dress up game on scratch || Scratch Tutorial for Beginner
Code For Kids
How to Make a Pong Game in Scratch || Scratch Tutorial for Beginner
Code For Kids
Scratch Tutorial || Day 6(part 1)
Code For Kids
Scratch Tutorial || Day 6( Part 2)
Code For Kids
Scratch Tutorial || Day 7
Code For Kids
Scratch Tutorial || Day 8
Code For Kids
How to Make Piano Game || Learn to Use Music Extension || Scratch Tutorial || Day 8
Code For Kids
How to Make Piano Game || Learn to Use Music Extension ||Scratch Tutorial for beginner
Code For Kids
Scratch Tutorial || Day 9
Code For Kids
Scratch Tutorial || Draw Shapes #shorts #codeforkids #youtubeshorts
Code For Kids
Scratch Tutorial |How to Draw Shapes in Scratch #scratch #scratchtutorials #codeforkids
Code For Kids
Day 10|| Scratch Tutorial
Code For Kids
Scratch Tutorial || Archery Tutorial
Code For Kids
#1 || Thunkable Beginner Tutorial Platform Overview
Code For Kids
App Development ||Tutorial 2 || how to add button in Thunkable || Thunkable for beginner #codeforkid
Code For Kids
App Development || Tutorial 3|| Beginner Tip "Change screens with a button click" in Thunkable
Code For Kids
Scratch Tutorial ||
Code For Kids
Thunkable Tutorial || Using Camera and Image Recognition components with Thunkable
Code For Kids
Build a Translator App with Thunkable ||Thunkable App Development || Tutorial 5||
Code For Kids
Thunkable Beginner Tutorial #6 || Web Viewer|| Redirecting App
Code For Kids
#1 World in Python || Python Tutorial || Python Programming || Google Colab
Code For Kids
#2 Python Tutorial for Beginners | User input in Python | Command Line Input | Python Variable
Code For Kids
#3 Python Comments | How To Write Comments In Python | Python Tutorial For Beginners |
Code For Kids
#4 Python Tutorial for Beginners | Data Types in Python
Code For Kids
#5 Numbers & Typecasting in python | Python Tutorial
Code For Kids
#6 Strings Tutorial | How To Use Strings In Python | Python Tutorial | Python Training |
Code For Kids
#7 Slicing And Other Functions In Python | Python Tutorials For Absolute Beginners.
Code For Kids
#8 Boolean in Python | Python Tutorial for Begniner
Code For Kids
#9 Python Tutorial for Beginners | Operators in Python
Code For Kids
#10 Lists And List Functions | Python Tutorials For Absolute Beginners
Code For Kids
#11 Tuple in Python | Python Tutorial
Code For Kids
#12 In Python | Python Sets Tutorial | Python Tutorial for Beginners | #python #pythonprogramming
Code For Kids
#13 If Elif Else Statement in Python || Python Tutorial for Beginners |
Code For Kids
#14 While Loop in Python ||Python Tutorial for Beginners
Code For Kids
Python Tutorial for addition of 2 numbers #shorts #youtubeshorts #codeforkids #pythonprogramming
Code For Kids
Python Tutorial for absolute Beginner|| While loop #pythonprogramming #shorts #youtubeshorts
Code For Kids
Machine learning for the kids with Scratch || Machine Learning for kids ||Day 1
Code For Kids
# Tutorial 1 || Machine Learning for kids | Image Classification example | Girl and boy
Code For Kids
#15 For loop in Python || Python Tutorial for Beginner
Code For Kids
# Tutorial 2 || Machine Learning for kids | Smart Home Automation | Turn On the Fan
Code For Kids
#Tutorial 3 || Snapchat Filter in Machine Learning|| Machine Learning for the kids ||
Code For Kids
#Tutorial 4 || Image Identification || Machine Learning for the kids|| Tiger , Elephant, boy
Code For Kids
Scratch Tutorial || Apple Catcher Game || Fruit Catcher|| catch game in Scratch
Code For Kids
Scratch Tutorial || How to record audio in Scratch || Scratch Tutorial for beginner ||
Code For Kids
Scratch Tutorial || how to translate language in scratch || Scratch tutorial for beginner
Code For Kids
Related Reads
📰
📰
📰
📰
Google Gemini Scene Extension Rolls Out Globally for AI Plus, Pro and Ultra Subscribers
Dev.to · Ali Farhat
What Happens to Tutoring When AI Knows Everything?
Medium · Startup
The NVIDIA DGX Spark Update That Quietly Uninstalled Its Own Dashboard
Medium · LLM
AI Game Art Is Not Engine-Ready Until You Define the Asset Contract
Dev.to · FrameSprite
🎓
Tutor Explanation
DeepCamp AI