-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables, datatypes & typecasting.py
More file actions
64 lines (44 loc) · 1.23 KB
/
variables, datatypes & typecasting.py
File metadata and controls
64 lines (44 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# # 1. Variables
# variables are like the container that stores data in it
var1 = 'Nitesh '
var2 = 11
var3 = 17.7
var4 = True
var5 = 'Kumar'
var6 = '10'
var7 = '60'
# print(var3)
# print(var4)
# how to concatenate two or more sting ?
# we can use '+' arthimetic opertators like :-
# print(var1+var5)
# we can also performe arthimatic operations like :-
# print(var2+var3)
# print(10*var1)
# # 2. Data type
# there are four major data types in python :-
# 1. string
# 2. integer
# 3. floating
# 4. boolean
# to check data type of any value we use type function
# print(type(var1))
# print(type(var2))
# print(type(var3))
# print(type(var4))
# # 3. Type casting
# we can change data type of one value into another using type casting
# we have many functions in type casting like :-
# int()
# float()
# str()
# boolean()
# print(int(var6)+int(var7))
# # 4. Input function
# input function recevies data from the user only in the string format and store it into variable
# name = input('Enter your name\n')
# print('User Input:',name)
######################## QUIZE TIME #########################
num1 = input('Enter your first number:\n')
num2 = input('Enter your second number:\n')
print('Sum of both numbers is',int(num1)+int(num2))