filmov
tv
Learn Python Part 3 Python Data Types, User Input and Type Casting

Показать описание
This video will cover following topics of python:
- Introduction to python data types
- Comments in python
- Concatenation
- User input
- Type casting
- Rules for identifiers in python
Following is the code used in this tutorial:
#Number Data Type
int_num = 10
float_num = 10.2
complex_number = 1.5j
long_numbers = 123456789
print("Number:", int_num, "Data Type: ", type(int_num))
print("Number: ", float_num, "Data Type: ", type(float_num))
print("Number: ", complex_number, "Data Type: ", type(complex_number))
print("Number: ", long_numbers, "Data Type: ", type(long_numbers))
#String Data Type
a_str = 'Hello World'
print("String: ", a_str, " Data Type: ", type(a_str))
print(a_str[0])
print(a_str[2:5])
#List Data Type
list=[123, 'abc', 10.2, 'd']
list1 = [1,3,4,5]
list2 = ['abc', 'def', 'ghi']
print(list[1])
print(list)
print(list1[0:2])
print(list2*3)
#Concatenation
s1 = 'Hello'
s2 = 'World'
print(s1 + s2)
list=[123, 'abc', 10.2, 'd']
list1 = [1,3,4,5]
print(list + list1)
#Dictionary Data Type
dic = {'name':'red', 'age':10}
print(dic)
print(dic['name'])
#Tuple data type
tuple = (123, 'hello')
tuple1 = ('world')
print(tuple)
print(tuple[0])
tuple[1] = 'hi'
#Type Casting
a = 8
print(type(a))
a = 'hello'
print(type(a))
# User input
print("Please enter some text: ")
a = input()
print("Entered Text: ", a)
print("enter first num: ")
a = int(input())
print("enter second num: ")
b = int(input())
print("sum of these two numbers is: ", a+b)
print(type(a))
print(type(b))
- Introduction to python data types
- Comments in python
- Concatenation
- User input
- Type casting
- Rules for identifiers in python
Following is the code used in this tutorial:
#Number Data Type
int_num = 10
float_num = 10.2
complex_number = 1.5j
long_numbers = 123456789
print("Number:", int_num, "Data Type: ", type(int_num))
print("Number: ", float_num, "Data Type: ", type(float_num))
print("Number: ", complex_number, "Data Type: ", type(complex_number))
print("Number: ", long_numbers, "Data Type: ", type(long_numbers))
#String Data Type
a_str = 'Hello World'
print("String: ", a_str, " Data Type: ", type(a_str))
print(a_str[0])
print(a_str[2:5])
#List Data Type
list=[123, 'abc', 10.2, 'd']
list1 = [1,3,4,5]
list2 = ['abc', 'def', 'ghi']
print(list[1])
print(list)
print(list1[0:2])
print(list2*3)
#Concatenation
s1 = 'Hello'
s2 = 'World'
print(s1 + s2)
list=[123, 'abc', 10.2, 'd']
list1 = [1,3,4,5]
print(list + list1)
#Dictionary Data Type
dic = {'name':'red', 'age':10}
print(dic)
print(dic['name'])
#Tuple data type
tuple = (123, 'hello')
tuple1 = ('world')
print(tuple)
print(tuple[0])
tuple[1] = 'hi'
#Type Casting
a = 8
print(type(a))
a = 'hello'
print(type(a))
# User input
print("Please enter some text: ")
a = input()
print("Entered Text: ", a)
print("enter first num: ")
a = int(input())
print("enter second num: ")
b = int(input())
print("sum of these two numbers is: ", a+b)
print(type(a))
print(type(b))