-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwelcome.py
More file actions
131 lines (131 loc) · 3.03 KB
/
welcome.py
File metadata and controls
131 lines (131 loc) · 3.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
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
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> print("welcome student")
welcome student
>>> print("hi");
hi
>>> name="Rohit"
>>> print(name)
Rohit
>>> #variable declaation & assignment
>>> a=20
>>> print(a)
20
>>> 1abc="raj"
SyntaxError: invalid decimal literal
>>> _ab2=80
>>> ABC=20
>>> #DATATYPE
>>> a=5
>>> print(a)
5
>>> print(type(a))
<class 'int'>
>>> a=10.6
>>> print(type(a))
<class 'float'>
>>> a=1+3j
>>> print(type(a))
<class 'complex'>
>>> a="Rajshri"
>>> print(a)
Rajshri
>>> a='Rajshri'
>>> print(a)
Rajshri
>>> list1=[1,2,"hi",10.4]
>>> print(list1)
[1, 2, 'hi', 10.4]
>>> print(type(list1))
<class 'list'>
>>> print(list1+list1)
[1, 2, 'hi', 10.4, 1, 2, 'hi', 10.4]
#list concatination using +operator
print(list1*3)
[1, 2, 'hi', 10.4, 1, 2, 'hi', 10.4, 1, 2, 'hi', 10.4]
print(list1*1)
[1, 2, 'hi', 10.4]
#list repetation using * opeartor
print(list1[3:])
[10.4]
print(list1[0:3])
[1, 2, 'hi']
t1=("abc",1.1,12)
print(type(t1))
<class 'tuple'>
print(t1)
('abc', 1.1, 12)
print(t1+t1)
('abc', 1.1, 12, 'abc', 1.1, 12)
('abc', 1.1, 12, 'abc', 1.1, 12)
('abc', 1.1, 12, 'abc', 1.1, 12)
print(t1*5)
('abc', 1.1, 12, 'abc', 1.1, 12, 'abc', 1.1, 12, 'abc', 1.1, 12, 'abc', 1.1, 12)
t[1]="rajshri"
Traceback (most recent call last):
File "<pyshell#38>", line 1, in <module>
t[1]="rajshri"
NameError: name 't' is not defined. Did you mean: 't1'?
t1[1]="rajshri"
Traceback (most recent call last):
File "<pyshell#39>", line 1, in <module>
t1[1]="rajshri"
TypeError: 'tuple' object does not support item assignment
d={101:'rohit',102:'mohit',103:'pranali'}
print(d)
{101: 'rohit', 102: 'mohit', 103: 'pranali'}
d={101:'rohit',101:'mohit',103:'pranali'}
d={101:'rohit',102:'mohit',103:'mohit'}
print(d)
{101: 'rohit', 102: 'mohit', 103: 'mohit'}
d={101:'rohit',101:'mohit',103:'pranali'}
print(d)
{101: 'mohit', 103: 'pranali'}
d[1]="ram"
print(d)
{101: 'mohit', 103: 'pranali', 1: 'ram'}
print(d[0])
Traceback (most recent call last):
File "<pyshell#49>", line 1, in <module>
print(d[0])
KeyError: 0
d={1:10,2:20,3:30}
print(d)
{1: 10, 2: 20, 3: 30}
print(d[2])
20
print(d[4])
Traceback (most recent call last):
File "<pyshell#53>", line 1, in <module>
print(d[4])
KeyError: 4
print(d.keys())
dict_keys([1, 2, 3])
print(d.values())
dict_values([10, 20, 30])
print(type(false))
Traceback (most recent call last):
File "<pyshell#56>", line 1, in <module>
print(type(false))
NameError: name 'false' is not defined. Did you mean: 'False'?
print(type(False))
<class 'bool'>
print(type(True))
<class 'bool'>
s1=set()#empty set
print(s1)
set()
s1={1,1.3,'hiiii',56}
print(s1)
{56, 1.3, 'hiiii', 1}
s1.add(100)
print(s1)
{1.3, 1, 100, 56, 'hiiii'}
s1.remove(2)
Traceback (most recent call last):
File "<pyshell#65>", line 1, in <module>
s1.remove(2)
KeyError: 2
s1.remove(56)
print(s1)
{1.3, 1, 100, 'hiiii'}