In [6]:

```
# Let's discuss some problem and lets try to solve this using python. Let's start very simple. lets consider a 3-deminsional vector. we need to give 3 components of the 3-dimensions. and let's calculate the magnitude of the vector
# Now lets, define the vector by entering the components of the vectors using the built-in function called input function in python
x = input("Enter x- compoent: "); #this would help us to enter the x-compoent of the vector
y = input("Enter y- compoent: "); #this would help us to enter the y-compoent of the vector
z = input("Enter z- compoent: "); #this would help us to enter the z-compoent of the vector
# after entering the compoents of the vectors we need to find the mod of the vector. but beofre that we have aproblem to solve to see that lets compile this once
```

Enter x- compoent: 2 Enter y- compoent: 3 Enter z- compoent: 4

In [7]:

```
x+y
```

Out[7]:

'23'

In [8]:

```
#in the above line we have asked python to add x and y i.e. 2+3 which is 5 but instead of 5 we got 23. why? becasue x, y, and z values are taken as strings but not as nmber. to perform our operation we need to make them numbers.
#to do that I can use the varable float. let's do one for example
a=float(input("enter number: "))
```

enter number: 4

In [20]:

```
#now lets do some operation with the number we entered
a+4
```

Out[20]:

8.0

In [21]:

```
# now lets calculate the modulus of the vector
r = (x**2+y**2+z**2)**0.5
```

In [25]:

```
# the above error occured because I forgot to take float on x, y, and z values.
#lets now write the entire code so that we could enter the desired values of the vector and find the modulus by clicking run once
x = float(input("Enter x- compoent: ")); #this would help us to enter the x-compoent of the vector
y = float(input("Enter y- compoent: ")); #this would help us to enter the y-compoent of the vector
z = float(input("Enter z- compoent: ")); #this would help us to enter the z-compoent of the vector
# now lets calculate the modulus of the vector
r = (x**2+y**2+z**2)**0.5
print("Modulus of the vector =",r)
```

In [29]:

```
#python goes from line by line, but this is not the case we can execute some lines without going through some lines. Let's do that in the next example
t = float(input("Enter the temperature"))
if t>=100:
print("Water is in vapour state")
elif 0<t<100:
print("It is in liquid state")
elif t<=0:
print("It is in solid state")
```

Enter the temperature100 Water is in vapour state