The thing i learned from python today are as follow:
- Tuples:
simply tuples is immutable which means that we can change the data again in list.
taking as an example:
list=(1,2,3,4)
print(list)
In tuples list are stored in curly bracket({}).
It is quite faster than that of list.
2.list:
simply we can say that list is mutable which means that we can edit the list as our wish anytime.
Take any list like :
list student={kapil , Prashant , rajan}
we can use function which are inbuilt ;
list. Append()=for adding element in list .
list .insert()=for adding an element wherever you like to .
list. Replace()=For replacing the data
and so in
it is quite slower comparing to tuples .
we can do list slicing i.e. can print the data from where we want by keeping some range.
numbers = range(5,10,2)
for number in range(5):
print(number)
In list data are stored in the square bracket ([ ]).
Data can be edited easily .
- function :
The most important part of this idea is def( define function )
CODE:
def sigma(to="world"):
print("noob,", to) # Added a space after the comma for better formatting
sigma()
name = input("What's your name? ")
sigma(name)
If you have any query related to above query than feel to ask.
CODE:
scope.....
return .....
def main():
name = input("What's your name?")
hello(name)
def hello(to="world"):
print("hello", name)
main()
That’s all for today’s python course..
Top comments (1)
Tuples wow nice