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

Python Session 4 Print Basic Codes

Uploaded by

ameen1ahmad06
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)
4 views4 pages

Python Session 4 Print Basic Codes

Uploaded by

ameen1ahmad06
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

variables

data types

type cast

In [ ]: int(10.5) # 10
int('10.5') # error
int(True) # 1
int('true') # error

float(10) # 10.0
float('10.5') # 10.5
float(True) # 1.0
float('true') # error

print statements

green color means either a keyword or an inbuilt function

any inbuilt function needs parnathses

In [ ]: type(10) # type of the number


print(10) # print the value
int(10.5) # 10
float(10) # 10.0
bool(1) # True
str(10) # '10'

In [3]: 10==10

Out[3]: True

In [5]: 10<0

Out[5]: False

In [ ]: False

In [ ]: type
False
eval
input
if
else

In [9]: input

Out[9]: <bound method Kernel.raw_input of <[Link] object at 0


x000001A1DBBE3FE0>>

In [11]: import os
[Link]

Out[11]: <function [Link]()>

if we miss the brackets we will get either of two indications

bound method

function

In [16]: print(10)

10

In [18]: n1=10
n2=20
n1
n2

Out[18]: 20

In [20]: n1=10
n2=20
print(n1)
print(n2)

10
20

In [22]: a=10
b=20
c=a+b
print(c)
# the addition of 10 and 20 is 30
# 30

30

In [48]: a=1000
b=2000
c=a+b
print(c)
print("the addition of 10 and 20 is 30")
print("the addition of 100 and 200 is 300")
print("the addition of a and b is c")
print("the addition of",a,"and",b,"is",c)

3000
the addition of 10 and 20 is 30
the addition of 100 and 200 is 300
the addition of a and b is c
the addition of 1000 and 2000 is 3000

In [54]: # name
# city
# age
# my name is python im 10 years old and im from hyd

name='python'
age=10
city='Hyderabad'
print("my name is python I am 10 years old and I am from Hyderabad")
print("my name is",name,"I am",age,"years old and I am from",city)

my name is python I am 10 years old and I am from Hyderabad


my name is python I am 10 years old and I am from Hyderabad

format

In [63]: a=100
b=200
c=a+b

print("the addition of 100 and 200 is 300")


print("the addition of {} and {} is {}".format(a,b,c))

the addition of 100 and 200 is 300


the addition of 100 and 200 is 300

In [69]: name='python'
age=10
city='Hyderabad'
print("my name is python I am 10 years old and I am from Hyderabad")
print("my name is {} I am {} years old and I am from {}".format(name,age,city))
print("my name is {} I am {} years old and I am from {}".format(city,age,name))

my name is python I am 10 years old and I am from Hyderabad


my name is python I am 10 years old and I am from Hyderabad
my name is Hyderabad I am 10 years old and I am from python

fstring

In [88]: a=100
b=200
c=a+b

print("the addition of 100$ and 200$ is 300$")


print("the addition of {}$ and {}$ is {}$")
print("the addition of {a}$ and {b}$ is {c}$")
print(f"the addition of {a}$ and {b}$ is {c}$")

the addition of 100$ and 200$ is 300$


the addition of {}$ and {}$ is {}$
the addition of {a}$ and {b}$ is {c}$
the addition of 100$ and 200$ is 300$

In [ ]: # wap ask the user take two number print subtraction multiplication and division
# wap ask the user take the radius find the area of circle
# area_of_circle=pi*r*r
# wap ask the user take height and breadth find the area of traingle
# area_of_traingle=0.5*b*h
# wap ask the user take 3 numbers find the average
# wap ask the user take the bill amount and tip anount calculate total bill
# wap ask the user take the salary, percetage of tax calculate tax amount
# wap ask the user take the value in dollar convert into rupees
# 1$=80rs
# wap ask the use take weight in kgs convert into pounds
# 1kg=2.2pounds
In [ ]: - are you using a proper variables

- are you proper quotes

- are you doing any spell mistakes

- are you using f string and format

You might also like