BA.Python_Prog-NEP-2024-Scheme (2)
BA.Python_Prog-NEP-2024-Scheme (2)
Code – 11E403/2211E403
Fourth Semester B.A./BSc./B.Com./B.B.A/B.S.W. Degree
Examination, August/September 2024
(UG-NEP -Scheme)
Computer Science
SECTION – A
Definition – Python is a high level programming language that contains the feautures
of functional programming language like C and object oriented programming language
like java.
Applications –
Web Development.
Game Development.
Machine Learning and Artificial Intelligence.
Data Science and Data Visualization.
Most of the programming languages like C, C++, Java use braces { } to define a
block of code. Python uses indentation. A code block (body of function, loop etc.)
starts with indentation & ends with the first unindented line. The amount of
indentation is up to you, but it must be consistent throughout that block. Generally,
four white spaces are used for indentation and is preferred over tabs.
e.g.: for i in
range(1,11):
print(i)
if i == 5: break
6. Define range () with its syntax.
The range data type represents a sequence of numbers. The numbers in the range are
not modifiable.
Syntax : range(start, stop, step)
Start – an integer number specifying which position to start.
Stop – an integer number specifying which position to stop.
Step – an integer number specifying incementation.
r=range(10)
Here, the range object is created with the numbers starting from 0 to 9
SECTION - B
II. Answer any FOUR questions : (4 x 5 = 20)
Q.P. Code – 11E403/2211E403
Binary Number System – In general, a binary number represents a 0 or 1 in the system. The
base or radix of the binary number system is 2. The possible digits that are used in a binary
number system are 0 and 1. If we wanted to store a binary number in python variable, that
number should starts with 0b.
Octal Number System - The base or radix of the octal number system is 8. The possible
digits that are used in the octal number system are 0 to 7. To represent an octal number in
Python, the number should start with 0 (python2) or ox (python3).
Decimal Number System - The base or radix of the decimal number system is 10. The
possible digits that are used in the decimal number system are 0 to 9. The default number
system followed by python is the decimal number system.
Hexadecimal Number System - The base or radix of the hexadecimal number system is 16.
The possible digits that are used in hexadecimal number systems are 0 to 9 and a to f. To
represent a hexadecimal number in Python, the number should start with 0x.
Q.P. Code – 11E403/2211E403
11. What is an algorithm? Write an algorithm to find the sum of two numbers.
Algorithms are a set of instructions that are executed to get the solution to a given
problem.
Step 1 : Start.
Step 2 : Read A,B.
Step 3 : Sum = A + B.
Step 4 : Print Sum.
Step 5 : Stop.
{ } into a string and calling the str.format(). The value we wish to put into the placeholders and concatenate
with the string passed as parameters into the format function.
To create an f-string in Python, prefix the string with the letter “f”. The string itself can be formatted in much the
same way that you would with str. format(). F-strings provide a concise and convenient way to embed
Python expressions inside string literals for formatting.
E.g., name =
'Ram'
print(f
"My
Q.P. Code – 11E403/2211E403
name
is
{name
}.")
n2 = 'GeeksforGeeks'
capitalize() Converts the first character of the string to a capital (uppercase) letter
isalnum() Checks whether all the characters in a given string is alphanumeric or not
num = 6
SECTION - C
III. Answer any FOUR questions : (4 x 7 = 28)
17. Convert :
(101101)2 = (45)10 (55)8 (2D)16
(AB5)16 = (101010110101)2 (5265)8 (2741)10
(307)10 = (100110011 )2
1. System software
If you think of software as being in layers, the system software is the bottom layer: it
sits between the hardware and the application software.
Operating systems like Windows, macOS, Android and iOS are examples of system
software. Operating systems are loaded into RAM when the device starts up, and have
access to the hard drive.
System software coordinates the activities and functions of hardware and software,
and it controls the operations of computer hardware.
2. Utility software
3. Application software
You can remove and add applications on your computer using the operating system.
Application software like a word processor regularly directs the operating system to
load and save files from and to the hard drive. When you are working on a file, it is
saved temporarily in the RAM. It is only when you choose to save it that it is written
to the hard drive.
Q.P. Code – 11E403/2211E403
if boolean-expression:
statement
• The reserved word if begins as if statement.
• The condition is a Boolean expression that determines whether or not the body will be
executed . A colon (:) must follow the condition.
• The block (one or more statements) is executed if the condition is true. The statements
within the block must be indented the same number of spaces from the left.
3. if_elif_else statement –
In python we can define a series of conditionals (multiple alternatives) using if for the
first one, elif for the rest, until the final (optional) else for anything not caught by the
other conditionals.
Syntax :
if condition1:
Statement 1
elif condition2:
Statement 2
else:
Statement 3
Q.P. Code – 11E403/2211E403
A function is a block of organized, reusable code used to perform a single, related action.
Functions provide better modularity and a high degree of code reusing.
3. Anonymous functions or Lambda functions - These functions are not declared in the
standard manner by using the def keyword. We can use the lambda keyword to create
small anonymous functions.
4. Recursion functions - A recursive function is one that invokes itself. Or A recursive
function is a function that calls itself in its definition. For example the mathematical
function, factorial, defined by factorial(n) = n*(n-1)*(n- 2)*...*3*2*1.