Python
Python
Python
Python is a popular programming language. It is created by Guido Van Rossum and released
in 1991. It is used for :- Web development, Software Development, Mathematic, System
Scripting.
2. What can Python do?
Python can be used on a serve to create3 web applications.
Used along site software to create work flows.
Connect to database system. It also read and modify files.
Used to handle big data and perform complex mathematics.
Used for rapid prototyping.
3. Why python?
Python works on deferent platforms.
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programmes with fewer lines then
some other programming language.
4. Reserve Words:- AND,BREAK,ASSERT,DEF,DEL,IT,ELITE,FOR
5. Indention :- White space beginning the line.
6. Arithmetic operator: +,-,*,/,%,//,**
7. Comparison operator: ==,!=,<,>,<=,>=
8. Unary operator:- if one operand compliment number . Exm:- b=-(a)
9. Bitwise operator:- &,|,^,~
10. Shift operator:- <<,>>
11. Logical operator: &&,||,!
12. Membership operators:- in, not in
13. String:- concatenation . Ex:- print(“abc”+”def”)
Output- abcdef
14. Repeat operation- Input :- print(“hello”,*5)
Output:- hello, hello, hello, hello, hello
Slice of String-
Input: String = 'GlobalInstitue'
s1 = slice(3)
s2 = slice(1, 5, 2)
print("String slicing")
print(String[s1])
print(String[s2])
Output :- String slicing
Glo
lb
15. Tuple:- A tuple is similar to the list as it also consists of an of values separates by ‘,’and
enclosed within parenthesis. The main defines between list and tuple is that you can change
the value in a list but not in a tuple. These means that tuple is read only data type.
16. Write a program to check weather a given number positive or not:-
print("Even Number")
else:
print("Odd Number")
22. Braek statement :- the break statement is used to terminate the execution of the nearest n
closing loop in within it appears. The statement is wildly used with for loop and while loop.
When the compiler encounters a break statements, the control passes to the statement that
follows the loop in which the break statement appears.
i=0
While(i>10):
Print(i,end=””)
If(i==5):
Break
i=i+1
23. Continue Statement:- the continue statement can appear in the body of a loop when the
compiler encounters a continue statements, then the rest of the statements in the loop are
skipped and the control is unconditionally transfer to the loop continues of the nearest
enclosing loop.
i=0
While(i>10):
If(i==5):
Continue
Print(i,end=””)
i=i+1
24. While loop:- While loop provide a mechanism to repeat one or more statement while a
particular condition is true.