CS NOTES
CS NOTES
A data type specifies the type of value a variable can hold, such
as numbers, text, or logical values like true/false.
What is a string data type?
A string(str) is a data type that represents text. It is a sequence
of characters enclosed in single (' ') or double (" ") quotes.
For example:
"Hello"
'Python'
Strings can include letters, numbers, spaces, and symbols. You
can perform operations like concatenation (joining) or slicing
(extracting parts) with strings.
Taking input: a=str(input(“enter word”))
Declaration: a=“A”
What is an Integer?
An integer (int) is a data type that represents whole numbers,
both positive and negative, without decimal points.
For example:
5
-10
0
Integers can be used for arithmetic operations like addition,
subtraction, multiplication, and division.
Taking input: a=int(input(“enter number”))
Declaration: a=12
What is float ?
A float is a data type that represents numbers with decimal
points.
For example:
3.14
-0.001
2.5
Floats are used when precision with decimal values is needed,
such as in measurements or calculations.
Taking input: a=float(input(“enter number”))
Declaration: a=3.14159
What are characters?
In programming, a character is a single letter, number, or
symbol. It is typically stored as a string of length 1, enclosed in
single or double quotes.
For example:
'A'
'9'
'#'
Characters are often used to represent individual elements in a
string or to manipulate text.
Taking input: a=char(input(“enter word”))
Declaration: a=“hi”
What is Boolean?
A Boolean is a data type that represents one of two possible
values: True or False. It is used to perform logical operations and
control the flow of programs.
For example:
True
False
Booleans are commonly used in conditions, like in if statements,
to check whether something is true or false.
Q. What is assignment and how to assign values in
python?
Ans : Assignment means to assign or set values to a variable.
Steps to assign variable
We need to name the variable.
By using the assignment operators the value will be given.
As example : a=5
Variable value
2. print() Function
The print() function is used to display messages, numbers, or
variables on the screen. By default, each print() statement moves
to a new line. You can print text, numbers, or a combination of
both.
Example:
print(“bye")
Python libraries
What is a Python Library?
A Python library is a collection of ready-made code that helps
you perform specific tasks without writing everything from
scratch. Libraries save time and make programming easier.
What is a variable?
Ans: A variable is a name that holds a value, like text or
numbers. It helps store and use data in a program . It
changes depending on the context of the program.
Conditional statement programs