What is operators: Operators in general are used to perform operations on values and variables.
Types of operators:
- Arithmetic operators: It is used to perform basic mathematical operations like addition, subtraction, multiplication etc.
- Comparison operators: It is used to compare values and it will return either true or false according to the given condition.
- Logical operators: It is used to perform Logical AND, Logical OR and Logical NOT operations. This is used to combine conditional statements. 4.** Assignment operators:** It is used to assign values to the variables. This is used to assign the value of right side of the expression to the left side operand.
Formatted string(f): It is used to insert variables or values directly inside a string.
name = input("What is your name ")
print("Your name is ",name)
age =int( input("What is your age "))
print("Your age is ",age)
gender = input("What is your gender ")
print("Your gender is ",gender)
print(f"Your name is {name} age {age} gender {gender}")
Output:
What is your name Vidya
Your name is Vidya
What is your age 20
Your age is 20
What is your gender Female
Your gender is Female
Your name is Vidya age 20 gender Female
By default, input from the user will be stored as string.
Typecasting: It means converting from one data type to another. There are two types of typecasting are there :
- Implicit typecasting : It automatically converts from one data type to another without writing any extra code.
- Explicit typecasting : It is manually converting from one data type to another type by the programmer.
String: It is a sequence of characters used to represent data. This can be given inside single quote(' '), double quote(" ") and triple quote(""" """) for multiple strings.
Indexing: This means accessing the individual elements using their position number index position.
Negative indexing: This means accessing elements from the end of a sequence using negative numbers.
Slicing: This means extracting a part from a sequence like a string,list.
Conditional Statements: This is used to make decisions in a program. They help the program choose what to do based on the given condition.
Types of conditional statements:
- if statement - This is used to execute code only if the condition is true.
- if-else statement - This is used when there are two choices.
- elif statement - This is used when there are multiple conditions.

Top comments (0)