0% found this document useful (0 votes)
3 views3 pages

Python

The document outlines the rules for naming variables in Python, including restrictions on starting characters, special characters, and length. It lists five data types (integer, float, string, complex, bool) and describes various operators, including unary, binary, and ternary operators, with a focus on binary operations. Additionally, it provides examples of input handling, arithmetic operations, and control structures such as conditionals and loops.

Uploaded by

ganesh ganeshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Python

The document outlines the rules for naming variables in Python, including restrictions on starting characters, special characters, and length. It lists five data types (integer, float, string, complex, bool) and describes various operators, including unary, binary, and ternary operators, with a focus on binary operations. Additionally, it provides examples of input handling, arithmetic operations, and control structures such as conditionals and loops.

Uploaded by

ganesh ganeshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Rules in python

1) VARIABLE SHOULD START WITH A LETTER


2) SPCL CHAR IS NOT ALLOWED
3) SPACES ARE NOT ALLOWED
4) ONE SPCL SHARECTER UNDERSCORE (_) IS ALLOWED
5) RESERVE OR KEY WORKS CANNOT BE USED
6) VARIABLE NAME SHOULD NOT EXCEED 32 CHARACTER

five data types

1)interger
2)float
3)string
4)complex
5)bool

operators in python

1)unary operators
2)binary operators
3)ternary operators

python only binary operators

opnd1
op
opnd1

4 binary ops

arithmetic - ( + , - , * , / , % , // (floor division) , ** (exponent) )


logical - ( AND , OR , NOT , XOR )
relational/comparision - ( < , > , <= , >= , != , = )
shift ops - ( << (left shift) , << (right shift) )

'''

Input()
(n1) = float(input("Enter 1st number :"))
(n2) = float(input("Enter 2nd number :"))

print("The values are :",n1,n2)


print("The sum of the values are :",n1 + n2)
print("The difference of the values are :",n1 - n2)
print("The product of the values are :",n1 * n2)
print("The quotient of the values are :",n1 / n2)
print("The remainder of the values are :",n1 % n2)3

'''

'''

amount = int(input("Enter the amount to be converted into denominations:"))


Thousand=amount//1000
amount=amount%1000
five_hundred=amount//500
amount=amount%500
one_hundred=amount//100
amount=amount%100
fifty=amount//50
amount=amount%50
tens=amount//10
amount=amount%10
ones=amount//1
print("No of 1000's :",Thousand)
print("No of 500's :",five_hundred)
print("No of 100's :",one_hundred)
print("No of 50's :",fifty)
print("No of 10's :",tens)
print("No of 1's :",ones)

'''

control structures

I)conditional

II)uncondition
1)iterative statement
1) Loops - For and while
2)selevtive statement
1)if condition
*if * if else * nested if * ladder if(elif)
2)match condition

x = int(input("Enter 1st number:"))


y = int(input("Enter 2nd number:"))

if x>y :
print("Maximum of",x,"and",y,"is",x)
else :
print(f"Maximum of {x} and {y} is {y}")

additional ops,

1.Membership Ops (in and not in)


2.Identity Ops (is and is not).

chr(ascii value)=character
ord(character)=ascii value
bin(binary conversion)
Hex(hexadeciamal value)

escape sequence
\n
\t
\v
\r
\\
\'
\"

You might also like