0% found this document useful (0 votes)
12 views4 pages

Hi

Uploaded by

v.srisanth.no1
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)
12 views4 pages

Hi

Uploaded by

v.srisanth.no1
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/ 4

Arithmetic operators

- `*` used for multiplication of variables

```python
# run: true
a=4
b=5
print(a*b)
```

- `+` used for addition of variables.

```python
a=4
b=5
print(a+b)
```

-
- `/` used for division of variables

```python
a=4
b=5
print(a/b)
```

- `-` used for subtraction of variables

```python
a=4
b=5
print(a-b)
```

- `//` used for floral division of varibles with constant

```python
dividend = 10
divisor = 3
result1 = dividend // divisor
print("Floor division of two integers:", result1) # Output: 3
```

- `%` used for modulus opertation

```python
name = "John"
age = 80
print("%s is %d years old" % (name, age)) # Output: "John is 80 years old"

```

- double-quotes = `"`
- used for initializing strings

```python
# this is an example for different kinds of string initialization
first = "Hello"
second = 'World'
third = """
hello
world
"""
print(f"first {first}, second {second} third {third}")
```

- **String**
- **function**
- **f-strings - formatted strings**

### My First Project

```python
# variable stored in memory when the python code
# assign total_days , 643
total_days = 643
x = 65 // 8

# // operation means quotient


years = total_days // 365

# dividend = divisor*quotient + remainde


# % remainder 643 - 365 = 278
remaining_days = total_days % 365

months = remaining_days // 30
remaining_days = (remaining_days % 30)

print(f"{total_days} days is approximately {years} years, {months} months, and


{remaining_days} days .")

```

```python
#use**(1/2) for under root of amy given value
#use**(2) for square of amy given value
#and so on

```

Assignment Operators it is used to assign the value, variable and function to


another variable.

### Assignment operators

• Operator Addition (+=)

```python
a=10
b=20
a+=b
print(a)
```
• Operator Subtraction(-=)

```python
a=10
b=20
a-=b
print(a)
```

- Operator Multiplication (*=)

```python
a=10
b=20
a*=b
print(a)
```

- Operator Division (/=)

```python
a=10
b=20
a/=b
print(a)
```

### Relational operators

Relational operators are used to compare the operand values on either side.

- Lesser than

```python
d=20
z=80
g=d>z
print(g)

#returns false because 80 is greater than 20


```

- Greater than

```python
a=10
b=5
c=a>b
print(c)

#returns true because 10 is greater than 5


```

- Greater than or equal to

```python
x = 5
y = 3
print(x >= y)

# returns True because five is greater, or equal, to 3

```

- Lesser than or equal to

```python
x = 5
y = 3

print(x <= y)

# returns False because 5 is less than or equal to 3

```

### Logical oerators

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy