10 March, 2015

Infosys Campus Connect Python Webinar Series-Post work1(on or before 11th March 2015)

Dear Students,

Submit the postwork-1 to T&P cell through department coordinator on or before 11th March 2015.We will not consider any submission after this date. Please submit your own work. Avoid copying from other groups, may lead to cancellation of both the teams’ from participation in this webinar series. 

Post Work 1 – Questions:

1. Why does “spam” show up in so many Python examples in books and on the Web?

2. Consider the following three statements. Do they change the value printed for A? [Yes/No and give reason]
A = "Infosys"
B = A
B = "India"

3. Consider these three statements. Do they change the printed value of A? [Yes/No and give reason]
A = ["Infosys"]
B = A
B[0] = "India"

4. How about these—is A changed now? [Yes/No and give reason]
A = ["Infosys"]
B = A[:]
B[0] = "India"

5. Practice using the Python interpreter as a calculator and give answers
a. The volume of a sphere with radius r is 4/3 πr3. What is the volume of a sphere with radius 5?
b. Suppose the cover price of a book is Rs.24.95, but bookstores get a 40% discount. Shipping costs Rs.3/- for the first copy and 75 paise for each additional copy. What is the total wholesale cost for 60 copies?
c. If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 per mile), then 3 miles at tempo (7:12 per mile) and 1 mile at easy pace again, what time do I get home for breakfast?
d. Assume that we execute the following assignment statements:
>>>width = 17
>>>height = 12.0
>>>delimiter = '.'
For each of the following expressions, write the value of the expression and the type (of the value of the expression).
i. width/2
ii. width/2.0
iii. height/3
iv. 1 + 2 * 5
v. delimiter * 5

6. Find the output:
a. How many characters are there in the string "\\a\n\nb\x1f\000d"?
b. What is the output of the below program?
a = [1,2,3,None,(),[],]
print len(a)
c. What gets printed?
x = 4.5
y = 2
print x//y
d. What gets printed?
nums = set([1,1,2,3,3,3,4])
print len(nums)
e. Will the following code successfully print the days and then the months
>>>daysOfWeek = ['Monday',
              'Tuesday',
              'Wednesday',
              'Thursday',
              'Friday',
              'Saturday',
              'Sunday']

>>>months =             ['Jan', \
                      'Feb', \
                      'Mar', \
                      'Apr', \
                      'May', \
                      'Jun', \
                      'Jul', \
                      'Aug', \
                      'Sep', \
                      'Oct', \
                      'Nov', \
                      'Dec']

>>>print ("DAYS: %s, MONTHS %s" % (daysOfWeek, months))

7. Given a string s with the value "g,oo,d", name two ways to extract the two characters in the middle.

8. What is the significance of import this statement in Python?

9. Find the output
a. What is the result of this code?
a = {'a':1,'b':2,'c':3}
a['a','b']
b. What is the result of this code?
a = {(1,2):1,(2,3):2}
a[1,2]
c. What is the result of this code?
a=[1,2,3,4,5,6,7,8,9]
a[::2]
d. What will be placed in a?
a = {'a': 1,'b':2, 'a':3}
e. What will be placed in a?
a = [1,2,3]
a[-3:-1] = 10,20,30,40

10. Which of the following statements is NOT true about Python?
a. Python's syntax is much like PHP
b. Python can be used for web development
c. Python can run on any type of platform
d. Python can be used to generate dynamic web pages




Infosys Campus Connect Daily : Tech Kaleidoscope : 2020/028

Dear All Dear Professor, Greetings from Infosys Campus Connect Team!!! Please find below some informat...