-
Notifications
You must be signed in to change notification settings - Fork 0
/
campusx_session_1.py
148 lines (113 loc) · 3.28 KB
/
campusx_session_1.py
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#****************python output***********
print("hello world")
#Print("hello world") ----> python is a case sensitive language
print("salman khan") #string
print(7) #integer
print(7.7) #float
print(True) #boolean
print("rajnish",7,False,45) #many datatypes print at a time
print('Hello',1,4.5,True,sep='/') #here seperator is /, not ''
print("hello",end='-')
print("world")
#***************Data Types***************
#integer
print(8)
print(1e308) #1*10^308
#float/Decimal
print(7.3)
print(1.7e308) #1.7*10^308
# Boolean
print(True)
print(False)
# Text/String
print('Hello World')
# complex
print(5+6j)
# List-> C-> Array
print([1,2,3,4,5])
# Tuple
print((1,2,3,4,5))
# Sets
print({1,2,3,4,5})
# Dictionary
print({'name':'Rajnish','gender':'Male','weight':70})
# Type Function -----> they tell me the type of variable
print(type('rajnish'))
'''******************* Static Vs Dynamic Typing **********
********************** Static Vs Dynamic Binding **********
********************** stylish declaration techniques **********'''
# in c/c++ we use static typing but in pyhon we use dynamic typing
# int a=4 ----> this is static typing becuse in this we define the type(int)
# a= 4 -----> this is dynamic typing because in this we donot define the type like int,str
# Dynamic Binding
a = 5
print(a)
a = 'rajnish'
print(a)
# Static Binding
# int a = 5
# stylish declaration techniques
# first method
a = 1
b = 2
c = 3
print(a,b,c)
# second method
a,b,c = 1,2,3
print(a,b,c)
# third methodd
a=b=c= 5
print(a,b,c)
#***************Comments****************
# this is a comment
# second line
a = 4
b = 6 # like this
# second comment
print(a+b)
#************Identifiers*********
# You can't start with a digit
name1 = 'Rajnish'
print(name1)
# You can only use special chars -> _
_ = 'Rajnish'
print(_)
# identiers can not be keyword
# *************Keywords*********
# keywords are nothing but reserve word which cannot use like a identifiers (print,true,type,false,and more)
# ***********User Input*********
input1 = input("enter a number") # here the type of input1 is string
# *********TYpe Conversion ***********
input1 = int(input("enter a number")) # here the type of input1 is integer
# Implicit -----> in implicit the computer already know the datatype and perform operation
print(5+5.6)
print(type(5),type(5.6))
# Explicit ------> in Explicit when we add two opertion then computer donot know the datatype of both variable and throw error
# print(4 + '4')
# ***********Literals***************
# (a = 5) in this code 5 are literals
a = 0b1010 #Binary Literals
b = 100 #Decimal Literal
c = 0o310 #Octal Literal
d = 0x12c #Hexadecimal Literal
#Float Literal
float_1 = 10.5
float_2 = 1.5e2 # 1.5 * 10^2
float_3 = 1.5e-3 # 1.5 * 10^-3
#Complex Literal
x = 3.14j
print(a, b, c, d)
print(float_1, float_2,float_3)
print(x, x.imag, x.real)
string = 'This is Python'
strings = "This is Python"
char = "C"
multiline_str = """This is a multiline string with more than one line code."""
unicode = u"\U0001f600\U0001F606\U0001F923"
raw_str = r"raw \n string"
print(string)
print(strings)
print(char)
print(multiline_str)
print(unicode)
print(raw_str)