Day -02 of learning python programming language..

The thing i learned from python today are as follow:

  1. Tuples:

simply tuples is immutable which means that we can change the data again in list.

taking as an example:

<span>list</span><span>=</span><span>(</span><span>1</span><span>,</span><span>2</span><span>,</span><span>3</span><span>,</span><span>4</span><span>)</span>
<span>print</span><span>(</span><span>list</span><span>)</span>
<span>list</span><span>=</span><span>(</span><span>1</span><span>,</span><span>2</span><span>,</span><span>3</span><span>,</span><span>4</span><span>)</span>
<span>print</span><span>(</span><span>list</span><span>)</span>
list=(1,2,3,4) print(list)

Enter fullscreen mode Exit fullscreen mode

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 .

  1. 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..

原文链接:Day -02 of learning python programming language..

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享
No one can change another. But one can be the reason for another to change.
没人能改变另一个人,但是某个人能成为一个人改变的原因
评论 抢沙发

请登录后发表评论

    暂无评论内容