0% found this document useful (0 votes)
12 views

Python Basics

The document provides a series of Python programming examples demonstrating basic operations, variable assignments, and data types. It covers arithmetic operations, input/output functions, and assignment operators with corresponding outputs for each example. The content is structured in a tutorial format, making it suitable for beginners learning Python programming.

Uploaded by

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

Python Basics

The document provides a series of Python programming examples demonstrating basic operations, variable assignments, and data types. It covers arithmetic operations, input/output functions, and assignment operators with corresponding outputs for each example. The content is structured in a tutorial format, making it suitable for beginners learning Python programming.

Uploaded by

findmyphoneall
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PYTHON BASICS

#1
X=7
Print(x)
Output:7

#2
x=7
print(x)
y=8
z=x+y
print(z)
output: 7
15

#3
x=67
y=3
r=x/y
print(r)
output: 23.333333333

#4
x=67
y=3
r=x//y
print(r)
output:22 (for integer value we use //)

#5
name='pine'
Name='apple'
print(name)
print(Name)
output: pine
apple
#6
age=25
name='justin'
print("age=",age)
print("name=",name)
output:
age= 25
name= justin

#7
print("first line \n \n")
print("second line")
output:
first line
second line

#8
Name=input(“enter a name”)
Print(“hello”,name)
Output:
enter name:cherry
hello cherry

#9
a=input("enter something:")
print(a)
output:
enter something:hello how do you doing??
hello how do you doing??

#10
integer=98
float=56.67
sum=integer+float
print(sum)
output:
154.67

#11
integer=98
float=56.67
sum=integer+float
print("data type of sum",type(sum))
output:
data type of sum <class 'float'>

#12
a=7777
print(type(a))
b=89.78
print(type(b))
output:
<class 'int'>
<class 'float'>

#13
a=80
b=80.99
stra=str(a)
strb=str(b)
print(stra)
print(type(stra))
print(strb)
print(type(strb))
output:
80
<class 'str'>
80.99
<class 'str'>

#14
a=55.5
b=float(a)
print(b)
output:
55.5

#15
a=58.9
b=int(a)
print(b)
output:
58

#16
floatnumber=5.67
integer=int(floatnumber)
print("floatnumber:",integer)
print("integernumber:",floatnumber)
output:
floatnumber: 5.67
integernumber: 5

#17
a=45
sum=a+98
print(sum)
output:
143

#18
x=1
y=9.87
z=56.76666
sum=x+y+z
print(sum)
output:
67.63666

#19
a=67
b=78
result=a-b
print(result)
output:
-11
#20
a=67
b=45
result=a*b
print(result)
output:
3015

#21
a="fool\n"
result=a*3
print(result)
output:
fool
fool
fool

#22
result=13%5
print(result)
output:
3

#23
result=8%2.5
print(result)
output:
0.5

#24
result=2**5
print(result)
output:
32

#25
base=3.45
power=6.4
result=base**power
print(result)
output:;
2767.210573640718

MORE ASSIGNMENT OPERATORS


#1
x=10
x+=15
print(x)
output:
25
#2
x=10
x//=4
print(x)
output:
2

#3
print(10-4*2)
output:2

#4
print(10-4*2)
output:12

#5
print((5/5)*5)
output:5

You might also like