Skip to content

Commit d82cbe2

Browse files
committed
0 parents  commit d82cbe2

File tree

191 files changed

+26736
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+26736
-0
lines changed

README.md

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
### Aim
2+
3+
In this experiment, user will learn the concepts of string in Python programming language.
4+
To implement the operations that can be performed in a string.
5+
6+
### Theory
7+
8+
9+
<h3>String</h3>
10+
We can access a string using indexing. In a string each character is assigned with a unique index value which starts from 0. A string can be written in both single quotes and double quotes.
11+
Example : 'Hello World'<br>
12+
"Hello World"<br>
13+
s = "Hello World"<br>
14+
15+
Python allows negative indexing as well.
16+
Example : -1, -3, -5.
17+
Where -1 refers to the last index, -2 refers to second last index and so on.
18+
Printing here can be done by placing the string in single or double quotes after print.
19+
<br>
20+
print("Hello World")<br><br>
21+
22+
<h4>Concatenation</h4>
23+
A string in python is immutable i.e. it can not be changed once defined. But concatenation is still possible<br>
24+
s = 'Hello World'<br>
25+
s = s +"Example<br>
26+
Now the string will be as "Hello WorldExample".<br>
27+
<h4>Repetition</h4>This is a unique property of strings in Python programming language. When a string is multiplied with an integer, the characters of string are multiplied the same number of times.
28+
29+
Syntax : string*integer<br>
30+
s="k"<br>
31+
s=s*5<br>
32+
Now the string will be "kkkkk". It has repeated itself 5 times.<br>
33+
<h4>Slicing</h4>Slicing is done in Python to select or display the desired number of characters in a string. It is done with the help of symbol ':'.
34+
35+
Syntax : String[ index: ]
36+
<br>
37+
s="Hello World"<br> 1) s = s[2:]<br>
38+
39+
2. s = s[1:8]<br>
40+
Here the 1st example will give output "llo World". All the characters from and after second index is selected.
41+
In the 2nd example output will be "ello Wo". Characters between index number 1 and 8 are selected.
42+
43+
Length of a string can be calculated using the len function.
44+
Syntax : len("string")<br>
45+
len("Hello World"<br>
46+
It will return 11.<br>
47+
48+
### Procedure
49+
50+
<h4>Steps of simulator </h4><br>
51+
1.&nbsp;Select the problem.<br>
52+
2.&nbsp; Read the simulator details.<br>
53+
3.&nbsp;Enter the desired input you want to operate.<br>
54+
4.&nbsp; Press CALCULATE to proceed. <br>
55+
5.&nbsp;The code will be displayed <br>
56+
6.&nbsp;Press NEXT to see the execution of code. <br>
57+
7.&nbsp;Relevant line in the code will be highlighted.<br>
58+
8.&nbsp;The local variables will be shown in the Output Panel with their values.<br>
59+
60+
### Pre Test
61+
62+
1. Q.1 What is the output of the following code?
63+
str1="Virtual PythonLab"
64+
str1[3]='s'
65+
print(str1)
66+
<br>
67+
A.<input type="radio" name="but" id="rb11" onclick="click1();">&nbsp;Virtual Python Lab
68+
<br>
69+
B.<input type="radio" name="but" id="rb12" onclick="click1();">&nbsp;Virtual
70+
<br>
71+
C.<input type="radio" name="but" id="rb13" onclick="click1();">&nbsp;Error
72+
<br>
73+
D.<input type="radio" name="but" id="rb14" onclick="click1();">&nbsp;Virsual Python Lab
74+
<br>
75+
<p id = "p1"></p>
76+
<br>
77+
2. What is the output of given string??
78+
str1="Virtual"
79+
str2="Python"
80+
str3=str1+str2
81+
print(len(str3))
82+
<br>
83+
A. <input type="radio" name="but2" id="rb21" onclick="click2();">&nbsp;10
84+
<br>
85+
B. <input type="radio" name="but2" id="rb22" onclick="click2();">&nbsp;11
86+
<br>
87+
C. <input type="radio" name="but2" id="rb23" onclick="click2();">&nbsp;12
88+
<br>
89+
D. <input type="radio" name="but2" id="rb24" onclick="click2();">&nbsp;13
90+
<br><br>
91+
<p id = "p2"></p>
92+
<br>
93+
94+
3. What arithmetic operators cannot be used with strings?
95+
<br>
96+
A. <input type="radio" name="but4" id="rb41" onclick="click4();">&nbsp;+
97+
<br>
98+
B. <input type="radio" name="but4" id="rb42" onclick="click4();">&nbsp;*
99+
<br>
100+
C. <input type="radio" name="but4" id="rb43" onclick="click4();">&nbsp;-
101+
<br>
102+
D. <input type="radio" name="but4" id="rb44" onclick="click4();">&nbsp;All of the mentioned
103+
<br><br>
104+
<p id = "p4"></p>
105+
<br>
106+
4. What is th output of "virtual"+1+2+"python"
107+
<br>
108+
A. <input type="radio" name="but3" id="rb31" onclick="click3();">&nbsp;vitual3python
109+
<br>
110+
B. <input type="radio" name="but3" id="rb32" onclick="click3();">&nbsp;Error
111+
<br>
112+
C. <input type="radio" name="but3" id="rb33" onclick="click3();">&nbsp;virtual12python
113+
<br>
114+
D. <input type="radio" name="but3" id="rb34" onclick="click3();">&nbsp;virtualpython
115+
<br><br>
116+
<p id = "p3"></p>
117+
<br>
118+
5. 5 If y="123"what will be the the return type of type(y)?
119+
<br>
120+
A.<input type="radio" name="but" id="rb11" onclick="click1();">&nbsp;str
121+
<br>
122+
B.<input type="radio" name="but" id="rb12" onclick="click1();">&nbsp;int
123+
<br>
124+
C.<input type="radio" name="but" id="rb13" onclick="click1();">&nbsp;bool
125+
<br>
126+
D.<input type="radio" name="but" id="rb14" onclick="click1();">&nbsp;String
127+
<br>
128+
<p id = "p1"></p>
129+
<br>
130+
131+
### Post Test
132+
133+
1. What is the output of the following code?[A]
134+
class customer:
135+
def**init**(self,id):
136+
self.id=str(id)
137+
id="2010"
138+
obj=customer(2567)
139+
print(obj.id)
140+
<br>
141+
A.<input type="radio" name="but" id="rb11" onclick="click1();">&nbsp;. 2567
142+
<br>
143+
B.<input type="radio" name="but" id="rb12" onclick="click1();">&nbsp; Error
144+
<br>
145+
C.<input type="radio" name="but" id="rb13" onclick="click1();">&nbsp; 2010
146+
<br>
147+
D.<input type="radio" name="but" id="rb14" onclick="click1();">&nbsp; None
148+
<br>
149+
<p id = "p1"></p>
150+
<br>
151+
2. What is the output of following Python program?[B]
152+
text='Python is high-level programming language'
153+
words=text.split()
154+
l=len(words)
155+
print('Number of words of the text:%d'%l)
156+
<br>
157+
A. <input type="radio" name="but2" id="rb21" onclick="click2();">&nbsp; Error
158+
<br>
159+
B. <input type="radio" name="but2" id="rb22" onclick="click2();">&nbsp;5
160+
<br>
161+
C. <input type="radio" name="but2" id="rb23" onclick="click2();">&nbsp; 6
162+
<br>
163+
D. <input type="radio" name="but2" id="rb24" onclick="click2();">&nbsp;None of these
164+
<br><br>
165+
<p id = "p2"></p>
166+
<br>
167+
168+
3. What is the output when following code is executed?[C]
169+
str1="virtualpythonlab"
170+
print(str1[6::-2])
171+
<br>
172+
A. <input type="radio" name="but4" id="rb41" onclick="click4();">&nbsp;pylab
173+
<br>
174+
B. <input type="radio" name="but4" id="rb42" onclick="click4();">&nbsp; lautriv
175+
<br>
176+
C. <input type="radio" name="but4" id="rb43" onclick="click4();">&nbsp; lurv
177+
<br>
178+
D. <input type="radio" name="but4" id="rb44" onclick="click4();">&nbsp;pati
179+
<br><br>
180+
<p id = "p4"></p>
181+
<br>
182+
183+
4. What is the output of the following code?[D]
184+
defchangement(str1):
185+
char=str1[0]
186+
str1=str1.replace(char,'&')
187+
str1=char+str1[1:]
188+
returnstr1
189+
print(changement('this is the string'))
190+
<br>
191+
A. <input type="radio" name="but3" id="rb31" onclick="click3();">&nbsp;Syntax Error
192+
<br>
193+
B. <input type="radio" name="but3" id="rb32" onclick="click3();">&nbsp;this is the string
194+
<br>
195+
C. <input type="radio" name="but3" id="rb33" onclick="click3();">&nbsp;&his is &hes &tring
196+
<br>
197+
D. <input type="radio" name="but3" id="rb34" onclick="click3();">&nbsp;this is &he s&tring
198+
<br><br>
199+
<p id = "p3"></p>
200+
<br>
201+
202+
### References
203+
204+
<p style="font-size:100%; margin-top:2%">
205+
<br>
206+
www.learnpython.org/en/Basic_String_Operations

aim.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In this experiment, user will learn - <br>The concepts of string in Python programming language.
2+
<br>To implement the operations that can be performed in a string.

assesment.log

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=/pretest.json
2+
{
3+
_: [],
4+
f: [
5+
'/home/runner/work/exp-strings-iitk/exp-strings-iitk/experiment/pretest.json'
6+
],
7+
files: [
8+
'/home/runner/work/exp-strings-iitk/exp-strings-iitk/experiment/pretest.json'
9+
],
10+
c: 'assessment',
11+
contentTypes: 'assessment',
12+
'content-types': 'assessment',
13+
'$0': 'validate'
14+
}
15+
Validated true
16+
=/posttest.json
17+
{
18+
_: [],
19+
f: [
20+
'/home/runner/work/exp-strings-iitk/exp-strings-iitk/experiment/posttest.json'
21+
],
22+
files: [
23+
'/home/runner/work/exp-strings-iitk/exp-strings-iitk/experiment/posttest.json'
24+
],
25+
c: 'assessment',
26+
contentTypes: 'assessment',
27+
'content-types': 'assessment',
28+
'$0': 'validate'
29+
}
30+
Validated true

assets/css/bootstrap.min.css

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.slidecontainer {
2+
text-align: center;
3+
}
4+
5+
.slider {
6+
width: 10%;
7+
}
8+
9+
.text-box {
10+
padding: 7px 20px;
11+
margin: 8px 0;
12+
box-sizing: border-box;
13+
width: 14%;
14+
}
15+
16+
.legend { list-style: none; }
17+
.legend li { padding-bottom : 1.5vw; width: 20vw; }
18+
.legend span { border: 0.1vw solid black; float: left; border-radius: 50%;}
19+
.legend .grey { background-color: grey; }
20+
.legend .green { background-color: #a4c652; }
21+
.legend .black { background-color: black; }
22+
23+
.button-input {
24+
border-radius: 50vw;
25+
background-color: #288ec8;
26+
border: none;
27+
color: white;
28+
padding: 1%;
29+
margin-left: 1%;
30+
margin-right: 1%;
31+
padding-bottom: 1%;
32+
padding-top: 1%;
33+
padding-left: 2%;
34+
padding-right: 2%;
35+
}
36+
37+
.button-input:hover {
38+
background-color:gray;
39+
cursor:pointer;
40+
}
41+
42+
.comment-box {
43+
position: relative;
44+
padding: 1vw;
45+
width: 30vw;
46+
text-align: center;
47+
}
48+
49+
.instruction-box {
50+
position: relative;
51+
width: 100%;
52+
transition: width 0.2s ease-out;
53+
border: 0.1vw solid grey;
54+
z-index : 10;
55+
}
56+
57+
.collapsible {
58+
background-color: Transparent;
59+
color: "grey";
60+
cursor: pointer;
61+
width: 100%;
62+
border: none;
63+
text-align: center;
64+
outline: none;
65+
font-weight: bold;
66+
padding-top: 1%;
67+
padding-bottom: 1%;
68+
}
69+
70+
.collapsible::-moz-focus-inner {
71+
border: 0;
72+
}
73+
74+
.active, .collapsible:hover {
75+
background-color: "white";
76+
}
77+
78+
/*The unicode \25BE is for ▾ (Dropdown arrow) */
79+
.collapsible:after {
80+
content: "\25BE";
81+
color: "grey";
82+
font-weight: bold;
83+
float: right;
84+
margin-left: 5px;
85+
}
86+
87+
.active:after {
88+
content: "\25B4";
89+
}
90+
91+
.content {
92+
padding: 0 1.8vw;
93+
max-height: 0;
94+
overflow: hidden;
95+
transition: max-height 0.2s ease-out;
96+
background-color: "white";
97+
}

0 commit comments

Comments
 (0)