-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariables_and_DataTypes.py
More file actions
75 lines (45 loc) · 2.03 KB
/
Variables_and_DataTypes.py
File metadata and controls
75 lines (45 loc) · 2.03 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
65
66
67
68
69
70
71
72
73
74
75
a = 1
b= 3
print(a+b)
name = "Monu Chaudhary"
# Data Types
# | Data Type | Description | Example |
# | ---------- | -------------------------------- | ----------------- |
# | `int` | Integer numbers | `x = 10` |
# | `float` | Decimal (floating-point) numbers | `pi = 3.14` |
# | `complex` | Complex numbers | `z = 2 + 3j` |
# | `str` | Text or string | `name = "Monu"` |
# | `bool` | Boolean (True/False) | `is_valid = True` |
# | `NoneType` | Represents a null value | `x = None` | This means that notihing is present in varible
# Naming Rules
# | Rule No. | Rule Description |
# | -------- | -------------------------------------------------------------------------------------- |
# | 1️⃣ | **Names must start with a letter** (A–Z, a–z) or an underscore `_` |
# | 2️⃣ | The rest of the name can include **letters, digits (0–9), or underscores** |
# | 3️⃣ | **Names are case-sensitive** — `Name` and `name` are different |
# | 4️⃣ | You **cannot use Python reserved keywords** (like `if`, `while`, `def`, etc.) as names |
# Logical Operator are used by names. There are only 3 logical operators
c = True or False
d = True and False
e = not False
#Another method to use not operator
f = not(True)
print(e)
print(f)
# Type-Casting
r = 12
t = type(r) # class <int>
print(t)
s = float(r)
j = 12.23
u = int(j) #Conversion of float into int
print(s)
num = "21"
val = str(num) # Conversion of String into val
print(val)
num1 = input("Enter number 1 ") # This will take input it as a string
num2 = input("Enter number 2 ")
print("The sum is " , num1+num2) #It will conacat the string
intnum = int(input("Enter the first number "))
intnum1 = int(input("Enter the second number "))
print("The sum is ", intnum + intnum1)