Basic Python
Basic Python
'''
#Python
#python is a programmimg language
#programming means set of instructions send to hardware
#python is a versatile language
#versatile means it almost every field
#how to print hello world in python
#syntax
print("hello world")
#variables and datatypes
#variables are like containers to store values
#every value is a type of data
#we have different types of datatypes
#1.string
#2.int
#3.float
#4.bool
# string means sequence of characters it enclosed with single quotes or double
quotes
# capital letters
# small letters
# digits
# spaces and special characters and symbols
a="kishore"
print(a)
a="123"
print(a)
a="$#% *()"
print(a)
#int means whole numbers and natural numbers
#0-9 or 1-9
a=1
print(1)
#float means it stores decimal values
a=3.123
print(a)
#bool means it stores true or false datatype
a=True
print(a)
a=False
print(a)
#sequence of instructions
#in python it reads like sequence
a="kishore"
a="JP"
print(a)
#input output basics
#user taken input it reads like string
a=input()#input reads like string
print(a)
#string concatination
#joining/added together strings is called string concatination.here uses +
operator
a=input()
b=input()
print(a+" "+b)
#string repitation uses * operator
a=input()
print((a+" ")*2)
#length of string
a="kishore"
b=len(a)
print(b)
#accessing characters to strings
#we can access every character to string by using index
#index starts from 0
#syntax var[index]
#ex:kishore is a string index statrs from 0
#this string starts 0,1,2,3,4,5,6
a=input()
b=a[2]
print(b)
#string slicing
#obtaining a part in the string is called string slicing
#syntax var[start:end]
#note end is not included
a=input()
b=a[0:3]
print(b)
#type conversions
#to convert one datatype to another data type is called type conversion
# 1.str()
# 2.int()
# 3.float()
# 4.bool()
#int conversion
a=3.123
b=int(a)
print(a)
#float conversion
a=123
b=float(a)
print(b)
#bool conversion
c="True"
d=bool(c)
print(c)
#string conversion
a=123
b=str(a)
print(b)
#while conver string to int or float
#string must be in digits
#we can check the datatype by using type()
a=123
b=str(a)
c=type(b)
print(c)