DEV Community

KAPIL SHAH
KAPIL SHAH

Posted on

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:

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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (1)

Collapse
 
prashantcod profile image
Prashant Gyawali

Tuples wow nice

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →