Learning Day-04
Let's Learn Python
# Day-04
Built-in Data types:
python supports dynamic data typing.
In Programming, data type is an Important Concept.
Variables can Store of different types, and different types can do different things.
-> based on assigned values,automatically data type will be constructed
to a variable.
a=10
#a is int
b=20.45
#b is float
c="hello"
#c is string
two types .
1. simple types.
2. complex types (collection types)
1. simple:
------------------------
int
float
string --> str
boolean -->bool
name--> string
age --> int
income --> float
areYouMarried --> bool
----------------------
name = "Sreeram"
or
name = 'Sreeram'
-------------------------------
name = "xyz"
<var> = input(<prompting text>)
name = input("Name please ")
#string
age = int(input("Age "))
income = float( input("Enter monthly text "))
------------------------------------------
inc = int(float(input("Enter monthly income ")))
250.75# typed value
-------------------------------------
a=10
b=20.5
c = a + b
type(c)
#float
-------------------------
qualified = True
x = False
----------------------------------
s = "computer"
s[0]-->c
s[3]-->p
len(s) #8
s[len(s)-1] --> s[7] --> r
s[-1] --> from last first one. ---> r
s[-3] --> from last third one. --> t
slicing:
--------
s[startIndex : endIndex]
--> start Index includes.
--> end INdex excludes..
s = "computer"
s[0:4]--> 0,1,2,3 --> comp
s[3:7]--> 3,4,5,6
s[1:-1]
More on Strings and String Handling we will see in upcoming classes.
To Download This Material:please click on the below link:

Comments
Post a Comment