0% found this document useful (0 votes)
6 views19 pages

Pyhton Operators Cs

Uploaded by

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

Pyhton Operators Cs

Uploaded by

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

PYTHON

OPERATOR
S
Data types
variables
Python Character Set

keywords Identifiers
String operators

functions Comments

punctuators
Blocks and indentation
OPERATORS
An operator is used to perform specific mathematical or logical operation on values.

The values that the operators work on are called operands.

For example, in the expression 10 + num, the value 10, and the variable num are
operands and the + (plus) sign is an operator
Arithmetic Operators
Relational Operators
Logical Operators
Identity Operators
Identity operators are used to determine whether the value of a variable is of a
certain type or not.

Identity operators can also be used to determine whether two variables are referring
to the same object or not. There are two identity operators.
Membership Operators
Membership operators are used to check if a value is a member of the given sequence
or not.
Comments
Comments are used to add a remark or a note in the source code.

Comments are not executed by interpreter

In Python, a comment starts with # (hash sign). Everything following the # till the
end of that line is

treated as a comment and the interpreter simply ignores it while executing the
statement.
Identifiers
In programming languages, identifiers are names used to identify a variable, function,
or other entities in a

Program. The rules for naming an identifier in Python are as follows:


The name should begin with an uppercase or a lowercase alphabet or an underscore
sign (_). This

may be followed by any combination of characters a–z, A–Z, 0–9 or underscore (_).
Thus, an identifier

cannot start with a digit.

We cannot use special symbols like !, @, #, $, %, etc., in identifiers.


Program
Write a Python program to convert temperature in

degree Celsius to degree Fahrenheit. If water boils

at 100 degree C and freezes as 0 degree C, use the

program to find out what is the boiling point and

freezing point of water on the Fahrenheit scale.

(Hint: T(°F) = T(°C) × 9/5 + 32)


Program
Write a Python program to calculate the amount

payable if money has been lent on simple interest.

Principal or money lent = P, Rate of interest = R%

per annum and Time = T years. Then Simple Interest

(SI) = (P x R x T)/ 100.

Amount payable = Principal + SI.

P, R and T are given as input to the program.


Program

++A, B, C take x days, y days and z days

respectively to do the job alone. The formula to

calculate the number of days if they work together

is xyz/(xy + yz + xz) days where x, y, and z are given

as input to the program.


Program
Write a program to swap two numbers using a

third variable.
Program
Write a program that asks the user

to enter their name and age. Print a

message addressed to the user that tells the user

the year in which they will turn 100 years old.

You might also like