0% found this document useful (0 votes)
32 views3 pages

Sheet-4 Invo 2022-Python Programming

The document provides a set of true/false questions and coding exercises related to Python fundamentals. It tests knowledge of Python syntax, variables, data types, strings, operators, control flow and more. Multiple choice and short answer questions are provided to assess understanding of core Python concepts.

Uploaded by

pspc139
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views3 pages

Sheet-4 Invo 2022-Python Programming

The document provides a set of true/false questions and coding exercises related to Python fundamentals. It tests knowledge of Python syntax, variables, data types, strings, operators, control flow and more. Multiple choice and short answer questions are provided to assess understanding of core Python concepts.

Uploaded by

pspc139
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Creative thinking course 2022

Sheet-4 Python Programming Fundamentals


Question One
Give True False
1. Text following a # symbol is ignored by the computer
2. \n and \ t are examples of escape sequences
3. The Python interpreter prompt consists of three right-angle brackets
(>>>).
4. If (10*7)/7 is typed at the prompt and Enter pressed, the result is
displayed
5. Integer division produces a decimal result.
6. A variable is the same as a constant.
7. Python is a strongly typed language.
8. Python programmers must declare all variables.
9. Variable names can begin with numbers.
10. Variable names can end with numbers.
11. Information outside of quotations is known as a string.
12. input is to integers what raw _input is to strings
13. Information inside of quotations is known as a literal.
14. Using triple quotations makes it possible to continue a string on multiple
lines
15. a natural language has no ambiguity
16. Indentation in Python is used for cosmetic purposes only
17. In the equation a=b=c=10, c would have the value of 30.
18. The script print “The rain \\ in Spain” would output: The rain \ in
Spain
19. If C=“Stewie” then print C[1] would output: e
20. If x=“Exam” then print len(x) would output: 3

Question Two

…,Write a program that generates the first N terms of Fibonacci series 1,1,2,3,5 -1

2-Without the aid of a computer, work out the order in which each of the following
expressions would be computed and their value.
i. 2 + 6/4-3*5+1
ii. 17 + -3**3/2
iii. 26+3**4*2
iv. 2*2**2+2
.Verify your answer using Python

1
3- Without the aid of a computer, work out these successive expressions and give the values
of a, b, c and d upon completion. Then check your answer using a Python script:

a=4

b=9

c=5

d= a*2+b*3

Question Three
1. Write a Python program that prompts the user for two numbers, reads them in, and
prints out the product, labeled.

2. What is printed by the Python code?


s = ”abcdefg”
print s[2]
print s[3:5]

3. Given a string s, write an expression for a string that includes s repeated five times.

4. Given an odd positive integer n, write a Python expression that creates a list of all the
odd positive numbers up through n. If n were 7, the list produced would be [1, 3, 5, 7]

5. Write a Python expression for the first half of a string s. If s has an odd number of
characters, exclude the middle character. For example if s were “abcd”, the result would
be “ab”. If s were “12345”, the result would be “12”.

6. Given a positive integer n, write Python code that prints out n rows, each with one more
‘x’ on it than the previous row. For instance, if n were 4, the following lines would be
printed:
x
xx
xxx
xxxx
Write a python code to get the factorial of any number n .7

Question Four

2
3

You might also like