Home > Backend Development > Python Tutorial > python session day t payilagam

python session day t payilagam

Barbara Streisand
Release: 2024-11-25 22:41:13
Original
371 people have browsed it

python session day t payilagam

To know whether there is PYTHON programming language in our linux machine.

Just open the terminal and type python3 automatically it shows the version of the python what you are using and it opens the python language in the terminal also.

We can't create any application in Day 1. But we can do it in python.
Simply we can do operation in the terminal like.

>> 10+12
>> 22
>> 10*3
>> 30
>> 35/7
>> 5.0
>> 45-10
>> 35
Copy after login

like that....

to exit python from the terminal
just type exit() command in the terminal.

To copy anything in the terminal press ctrl shift c

to write the program open text editor in the linux

go to edit and select preferences select your own look

MY FIRST PROGRAM :

name = input("what is your name?")
print("Welcome to Python, name)


output:
What is your name ? RAJA
Welcome to python RAJA
Copy after login

after typing the program in the editor press ctrl s save the copy in the desktop .

to open desktop press ctrl D
press right click to open the terminal
type python3 and type your saved document
it shows the output

FUNCTIONS:
What is FUNCTIONS :
Set of instructions for achieving a specific task.

Example:
Watching_Meiyazhagan:
1) laptop_on
2) Netflix
3) Meiyazhagan
4) Play

If seen in brackets it is function

input() is a function
print() is a function
Mainly these are all pre-defined function.

Function can be performed without arguments also

#python# means comment python will not take that as code.

using pre-defined function

no1 = 100
no2 = 5
print(no1+no2)
print(no1-no2)
print(no1*no2)
print(no1/no2)

output :
105
95
500
20.0
Copy after login

user - defined function mainly used as code reusablity.

def add (Should be meaningful (if space required use it like sleeping_bed)

USING USER-DEFINED FUNCTION:

def calculate(no1, no2)
    print(no1+no2)
    print(no1-no2)
    print(no1*no2)
    print(no1/no2)

no1 = 100
no2 = 5
calculate(no1, no2)
Copy after login
output:
105
95
500
20.0
Copy after login

The above is the detailed content of python session day t payilagam. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template