CS project
CS project
INTERN
ATIONA
Summer Project
L
Subject: Comp. Sci.
SCHOOL
Class: XI-A
Student Name: Shikhar
Kumar
Submitted To: Mrs. Amoli
Chakraborty
2. Tokens:-
A token is the smallest individual unit in a python program.
All statements and instructions in a program are built with
tokens. The various tokens in python are :
1. Keywords: Keywords are words that have some special
meaning or significance in a programming language.
They can’t be used as variable names, function names,
or any other random purpose. They are used for their
special features. In Python we have 33 keywords some
of them are: try, False, True, class, break, continue, and,
as, assert, while, for, in, raise, except, or, not, if, elif,
print, import, etc.
Identifiers:
Identifiers are user-defined names used to represent
variables, functions, classes, objects, and other entities
in a program.
They are created by programmers to provide a unique
and meaningful name to elements within their code.
Identifiers must follow certain rules and conventions set
by the programming language, such as starting with a
letter or underscore, and consisting of letters, digits, or
underscores.
Examples of identifiers: variableName, functionName,
ClassName.
Keywords:
4. The program for taking two no. and printing their sum is:
A=float(input('Enter any real number:'))
B=float(input('Enter any other real number:'))
if A>B:
n=A-B
else:
n=B-A
x=int(n)
if n-x==0:
print('The difference between the given no.s is:', x)
else:
print('The difference between the given no.s is:', n)
Code:-
Output:-
5. A=3*4//5+5//7+8-2+4//2
=12//5+5//7+8-2+4//2
=2+0+8-2+2
=10
6. The program to give the first 5 multiples of a no. is:
n=int(input('Enter any- number:'))
print('The first 5 multiples are:', n, 2*n, 3*n, 4*n, 5*n)
Code-
Output-
7.
Type casting, also known as type conversion, is the process of
converting a value from one data type to another. It allows
you to change the interpretation or representation of data in
your program.
In Python, you can perform type casting using various built-in
functions. Here are a few examples:
Integer to Float Conversion:
integer_value = 5
float_value = float(integer_value)
print(float_value) # Output: 5.0
In this example, the float() function is used to convert an
integer value to a float value. The variable integer_value is
cast to a float using the float() function, resulting in the value
5.0.
8.
The program for the perimeter of a rectangle is:
l=float(input("Enter length of the rectangle:"))
b=float(input("Enter breadth of the rectangle:"))
P=2*(l+b)
p=int(P)
if P-p==0:
print("Perimeter of the rectangle is:", p, 'sq. cm.')
else:
print("Perimeter of the rectangle is:", P, 'sq. cm.')
Code-
Output-
9.
(i) (12/+a)%3 = 0
(ii) (21*+a)%9 = 6
(iii) (21//+a)%3 = 1
Code-
Output-