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

01 - Basics - Jupyter Notebook

The document is a Jupyter Notebook containing basic Python programming concepts, including data types, variables, and input/output operations. It demonstrates examples of type casting, arithmetic operations, and variable swapping techniques. The notebook also includes error handling for invalid inputs.

Uploaded by

nmdrafiqj2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

01 - Basics - Jupyter Notebook

The document is a Jupyter Notebook containing basic Python programming concepts, including data types, variables, and input/output operations. It demonstrates examples of type casting, arithmetic operations, and variable swapping techniques. The notebook also includes error handling for invalid inputs.

Uploaded by

nmdrafiqj2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

10/20/22, 4:10 PM _01_basics - Jupyter Notebook

In [1]:

language->communication
system user
0's and 1's assembly->key word
binary high level
machine
low level

translator or intermediator
complier interpeter
at a strect execution line by line execution
time taken is less time taken is more
error possiblity is more error possiblity is less

10

In [1]:

program->set of instruction or pattern to complete a task

File "<ipython-input-1-b1df5174fd0e>", line 1


program->set of instruction or pattern to complete a task
^
SyntaxError: invalid syntax

In [ ]:

#datatype
#data->collection of information
#variable
#()->function

In [1]:

a=10
b=20.5
c="raj"
d=True
print(a,b,c,d)

10
20.5 raj True

localhost:8888/notebooks/OneDrive/_01_python_class_notes/_01_basics.ipynb 1/4
10/20/22, 4:10 PM _01_basics - Jupyter Notebook

In [2]:

a=10
b=20.5
c="raj"
d=True
print(type(a),type(b),type(c),type(d))#()->fucntion->something to do

<class 'int'> <class 'float'> <class 'str'> <class 'bool'>

In [1]:

a=10
b=20
c=a+b
print(c)

30

In [2]:

a=input()
print(type(a))

raj
<class 'str'>

In [1]:

a=input("enter the string: ")


print(type(a))

enter the string: raj


<class 'str'>

In [4]:

#type casting
a=int(input())
print(type(a))

10
<class 'int'>

In [17]:

a=float(input())
print(type(a))

20
<class 'float'>

localhost:8888/notebooks/OneDrive/_01_python_class_notes/_01_basics.ipynb 2/4
10/20/22, 4:10 PM _01_basics - Jupyter Notebook

In [20]:

a=int(input())
b=str(a)
print(type(b))

10
<class 'str'>

In [6]:

a=(input())
b=int(a)
print(type(b))

fa

---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-6-d611c5a0378f> in <module>
1 a=(input())
----> 2 b=int(a)
3 print(type(b))

ValueError: invalid literal for int() with base 10: 'fa'

In [22]:

num1=int(input())
num2=int(input())
sum=num1+num2
print("sum is",sum)

10
20
sum is 30

In [ ]:

variable->name to store data


a
b
c
num
raj
raja
sekar
raj1
a1
b2
raja_sekar
_123
Raj
RAJ
XXXX
1as
shf sjdf
sjdj%ashhf

localhost:8888/notebooks/OneDrive/_01_python_class_notes/_01_basics.ipynb 3/4
10/20/22, 4:10 PM _01_basics - Jupyter Notebook

In [23]:

num1=int(input())
num2=int(input())
temp=num1
num1=num2
num2=temp
print(num1,num2)

10
20
20 10

In [24]:

num1=int(input())
num2=int(input())
num1=num1+num2
num2=num1-num2
num1=num1-num2
print(num1,num2)

10
20
20 10

In [25]:

num1=int(input())
num2=int(input())
num1,num2=num2,num1
print(num1,num2)

10
20
20 10

In [26]:

num1=int(input())
num2=int(input())
num1=num1^num2#xor
num2=num1^num2
num1=num1^num2
print(num1,num2)

10
20
20 10

localhost:8888/notebooks/OneDrive/_01_python_class_notes/_01_basics.ipynb 4/4

You might also like