100-Days OF Python-Day-02

 Day-02

In this class we will be studying about below topics in detail:

    a.Data Types
    b.Numbers
    c.Operators
    d.Type Conversion
    e.F-strings


Python Primitive Data Types:

String-
[0]--python string subscripting
print("123"+"234")
Output-123234-Instead of addition it will be string concatebation

Floating Point Number
13.5

Boolean Number
True ,False

# Type Error & Type Conversion & Type Checking:
Function only takes data types which are being defined for it .

Example: Machine for Potato into chips and puting rock in place of potato

Type Conversion & Type Casting (Type Checking)

WAP to print sum of digit of two number:
a=str(input("Type a two digit number:"))
a_1=a[0]
a_2=a[1]
A=int(a_1)
B=int(a_2)
C=A+B
print(C)

WAP for calculating BMI by taking input height and weight from user:
height=input("enter your height in m:")
weight=input("enter your weight in kg:")
BMI= float(weight)/float(height) ** 2
print(int(BMI))

Mathematical Operator:
 Round-To make round to nearest number
print(8//3)-No floating decimal in this and it is of int type.

F String:

It allows to print string and int together without type conversion Any kind of data can be combined together.
score=0
print(f"your score is {score}")

WAP for calculatig weeks and days left in your life assuming 90 years to be ideal life
age=int(input("Enter your age:"))
age_left=90-age
print(age_left)
days=age_left*365
weeks=52*age_left
months=12*age_left
print(f"You have {days} days,{weeks} weeks,{months} months left.")


Project For Day-02-Tip Calculator
print("Welcome To The Tip Calculator")
bill_amount=int(input("Enter the bill amount:"))
Tip_amount=int(input("What will be tip % :10,12 or 15?"))

Number_people=int(input("enter the number of people for bill sharing:"))

Per_head=float(bill_amount-Tip_amount)/Number_people

print(f"Each person should pay:{Per_head}")




Comments

Popular posts from this blog

Top 5 Best Books For Python,Data Science & Machine Learning

How To Start A BLOG

Top 50 Most Innovative Companies in 2020

Why Should We learn C Programming?

Blogger Tutorial