PYTHON LGS

 Introduction To Python.txt

Introduction to Python

Python is a widely used general-purpose, high-level programming language. It was created by Guido van Rossum, and released in 1991. 
It is used as a support language for software developers. Python ranks among the most popular and fastest-growing languages in the world.
World's biggest app "Instagram" uses Python on its backend. Uber also uses Python somewhere as its backend language.

Python is popular because:
1. Emphasis is on code readability, shorter codes, and ease of writing.
2. Closer to the English language and easy to Learn.
3. Inbuilt functions for almost all of the frequently used concepts.
4. Logical concepts are expressed in fewer lines of code in comparison to other languages such as C++ or Java.

Python is an interpreted language and a python interpreter is a program that knows how to execute a python code, it converts the code written 
in Python into a language that our computer can understand.

# Uses:
1. It is used to build web applications.
2. It provides GUI library to develop a user interface, ex - Tkinter, PyQt, etc.
3. It is used in software development.
4. It is used in Business Applications, ex- E-commerce.
5. Image Processing Applications.
6. Game Development.
7. Artificial Intelligence and Machine Learning.

# Features :
1. It is a case-sensitive language.
2. Indentations are used.
3. Variables are used without declaration.
4. It is a dynamically typed language.
5. It consists of a large library, etc.

# IDLE (Integrated Development and Learning Environment) Python-
It is a code editor which allows the user to write and execute a python program.
It provides two window options:

1. Interpreter Window: It allows us to enter commands directly into python. On pressing enter, python will execute it and display the result.
(Print function is not required)

2. Program Window: This window is purely for commands to be given. Programs are written , comments can be given and print statement is used to
obtain result/output.

theVeryBasics.py

#Output Function:

#print('Hello World')

#comments are identified by a # symbol
#comments are written by a programmer to write his thought 
#process while writing the code

#indentation
#it refers to adding whitespaces at the beginning of a statement.

#-----------------------------------------------------------------

# -------end-------
#end = "" is used to add two strings

print("Hello World", end=" ")
print("it's a Lovely day !")

#---------------------------------------------------------------

# Escape Sequence Characters:

#An escape character is a backslash '\' followed by any
#character needed to insert
# \n - newline character
# \t - tab
# \' - single quote
# \" - double quotes
# \\ - backslash

# print('Hello \nWorld')
# print('hello\tWorld')
# print('Father\'s name')
# print("\"All\'s well that ends well\"")
# print('This inserts a backslash\\ in a string')

home.py

name = "xyz"
age = 12


##print(name)
##print(age)

name1 = input("please enter your name: ")
age = input("enter age: ")
##print("the name is", name1, "and the age is", age)


# format method:

print("the name is {} and the age is {}".format(name1,age))


# formatted string:

print(f"the name is {name} and the age is {age}")

theBasicFunctions.py

#Raw String:

##Raw string are used to write something as it is.
##it doesn't escape any character and treats single backslash as
##literal character.

##print(r'Hello \nWorld')
##print(r'hello\tWorld')
##print(r'"\"All\'s well that ends well\""')




#---------input() Function------------------------------
##In Python, you can take input from the user using the input()
##function.

##userInput = input('enter something:' )
##print(userInput)
##
##name = input('enter your name: ')
##print('Hello' ,name)




##---------type() Function ------------------------
##In Python, The type() function is used to check the type of an object.

# a = 'orange'
# print(type(a))

# b = '12'
# print(type(b))

# c = 3
# print(type(c))

# d = 3.2
# print(type(d))

# e = 'true'
# print(type(e))

# f = True
# print(type(f))





# ------------- Format() Method -------------
##In Python, the format() method is used to create formatted strings.
##It helps you build strings where you can insert values or
##variables in specific positions within the string.

##name = 'xyz'
##Hobby = 'Programming'
##
##print('My Name is {}, My Hobby is {}.'.format(name,Hobby))

##userName = input('enter your name: ')
##age = input('enter your age: ')
##print('My name is {}, I am {} years old.'.format(userName,age))


##---------formatted string------------

##print(f'My Name is {name}, My Hobby is {Hobby}.')

##print(f'I am {userName} and i am {age} years old.')

arithmeticOperators.py

#Arithmetic Operators in Python:

print(2+2)
print(2-2)
print(5*2)

x = 20
y = 2

print("addition: ",x+y)
print("subtraction: ",x-y)
print("multiplication: ",x*y)

print("division: ",x/y)    # normal division in python

#-------------------------------------------------------------

# modulo (%):
# modulo gives you the remainder.

print("remainder: ",x%y)

#-------------------------------------------------------------

# floor divison in python(//):
# floor gives you the quotient.

print("quotient", 11//3)


#--------------------------------------------------------------

# Comparison operators in Python:

#  >   greater than operator 
#  <   less than operator
#  >=  greater than equal to
#  <=  less thaneq ual to
#  ==  equal to operator
#  !=  not equal to operator

a = 10
b = 6
print(a>b)  
print(a<b)  

print(a>=b)
print(a<=b)

print(a==b)
print(a!=b)

print(a==10)

#------------------------------------------------------------

## raise to the power:

print(2**2)      # prints the square of a number
print(2**3)      # prints the cube of a number

Comments

Popular posts from this blog

Java

COMPUTER GRAPHICS IN BCA 3 YEAR