Q. In Spyder IDE, click --> File New File... and type the following code into it:


#This is another program with different components

#Function First5Multiples() follows
def First5Multiples():
    print ("6 * 1 =", (6*1))
    print ("6 * 2 =", (6*2))
    print ("6 * 3 =", (6*3))
    print ("6 * 4 =", (6*4))
    print ("6 * 5 =", (6*5))

# main code follows
print ("Hello")
b = 3
print ("Function First5Multiples() will print ", b + 2, "multiples of 6.")
First5Multiples() #function First Multiples() being called

if b + 2 > 5:
    print ( "The function printed ", b + 2, " multiples of 6.")
    print ("Python is amazing!")
    print ("I have started enjoying myself.")


Now save your code by pressing Ctrl + S or using File --> Save command.
Being in same window, run your code by pressing F5 key.
Now in the following boxes fill in the appropriate components of a program from the above code.



(a) Name the components in the above code

Name what all components do you see in above code, e.g. expression, statement etc.


(b) Number of Comments in the given code


(c) Number of full-line comments


(d) Number of inline comments


(e) The full-line comments

Write full-line comments from the above code:


(f) Inline comments

Write inline comments from the above code:


(e) Number of Expressions in above code

(Don't worry it all expressions could not be picked up. Idea is to identify expressions and statements).


(h) Expressions

Write expressions (in above code) below:


(i) Number of Statements in above code


(j) Statements

Write Statements (in above code) below:


(k) Number of blocks/code-blocks in above code


(l) Blocks in above code

Write below (the code blocks): (Do not write complete code, just the first line that requires block and the count of code lines in it.)


(m) Number of functions in above code


(n) Give function name and how many statements a part of Write below:


Answer =

(a)
Components:-
1. Comment
2. Function
3. Expressions
4. Statements
5. Block

(b) Number of comments: - 4

(c) Number of full-line comment: - 3

(d) Number of inline comment: - 1

(e)

# This is another program with different components
# Function First5Multiples () follows
# main code follows

(f)

#function First Multiples () being called

(g) Number of expressions: - 9

(h)

print ("6 * 1 =", (6*1))
print ("6 * 2 =", (6*2))
print ("6 * 3 =", (6*3))
print ("6 * 4 =", (6*4))
print ("6 * 5 =", (6*5))

b = 3
print ("Function First5Multiples() will print ", b + 2, "multiples of 6.")

if b + 2 > 5:
    print ( "The function printed ", b + 2, " multiples of 6.")

(i) Number of Statements:- 13

(j)

print ("6 * 1 =", (6*1))
print ("6 * 2 =", (6*2))
print ("6 * 3 =", (6*3))
print ("6 * 4 =", (6*4))
print ("6 * 5 =", (6*5))

print ("Hello")
b = 3
print ("Function First5Multiples() will print ", b + 2, "multiples of 6.")
First5Multiples()

if b + 2 > 5:
    print ( "The function printed ", b + 2, " multiples of 6.")
    print ("Python is amazing!")
    print ("I have started enjoying myself.")

(k) Number of blocks: - 2

(l)

def First5Multiples():
    print ("6 * 1 =", (6*1))
    print ("6 * 2 =", (6*2))
    print ("6 * 3 =", (6*3))
    print ("6 * 4 =", (6*4))
    print ("6 * 5 =", (6*5))

if b + 2 > 5:
    print ( "The function printed ", b + 2, " multiples of 6.")
    print ("Python is amazing!")
    print ("I have started enjoying myself.")

(m) Number of function: - 1

(n)

def First5Multiples():
    print ("6 * 1 =", (6*1))
    print ("6 * 2 =", (6*2))
    print ("6 * 3 =", (6*3))
    print ("6 * 4 =", (6*4))
    print ("6 * 5 =", (6*5))

* Function have 5 statements

5 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. hey thanks for spending ur time to make this amazing site which is very useful for us i really appreciate it :D

    ReplyDelete
  2. can you please make it available in pdf format

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post