Skip to content

Commit 1e949a3

Browse files
author
sdevikar
committed
added basic operations demo
1 parent 868068c commit 1e949a3

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

python2/basic_operations.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# simple arithmetic operations:
2+
number = 1+2*3/4.0
3+
print number
4+
5+
# using operators with strings
6+
print "My name is " + "Swapnil " + "Devikar"
7+
8+
# *interesting* print the same string multiple times
9+
print "Don't Stop! " * 5
10+
11+
12+
# *interesting* support for repeating the list
13+
# this will create a list that repeats the original list 3 times
14+
print [1, 2, 3] * 3
15+
16+
# Exercise
17+
# create two lists called x_list and y_list, which contain 10 instances of the
18+
# variables x and y, respectively. You are also required to create a list called
19+
# big_list, which contains the variables x and y, 10 times each, by
20+
# concatenating the two lists you have created.
21+
22+
x = 3
23+
y = 2
24+
25+
x_list = [x] * 10
26+
print x_list
27+
28+
y_list = [y] * 10
29+
print y_list
30+
31+
big_list = x_list + y_list
32+
print big_list

0 commit comments

Comments
 (0)