1 Python was developed by Guido Van Rossum.
2 Register is the temporary place to store data for the purpose of correct calculation.
3 In two ways we can work in Python- (i) Interactive mode (ii) Script Mode
5 Flowchart is a pictorial representation of definite number of steps in a given program.
6 Cross platform language means a language can run equally on variety of platforms-Windows,
Linux/UNIX, Macintosh, Supercomputers, Smart phones etc.
7 ASCII stands for American Standard Code for Information Interchange
8 Python has one special literal, which is None. The None literal is used to indicate absence of value.
It is also used to indicate the end of lists in Python. It means ―There is nothing here.
9 This code will assign 18 to a and b both.
10 Data type is a way to tell the interpreter that what type of data a variable is storing in it, what
operation can be performed on such type of data.
11 The syntax of if-elif statement in python is as follows:
If condition1:
#code-block of statements when condition1 is true
elif condion2:
#code-block of statements when condition2 is true
elif condition3:
#code-block of statements when condition3 is true
...
else:
#code-block of statements when all above conditions are false.
12 (C)
13 Storage devices: Pen drive, CD/DVD,Memory Card,flash drives,blue-ray discs
14 base is 16
15 X.(X’+Y)
16. Python supports two types of strings: (i) Single-line string That terminates in single line.
(ii) Multi-line String That stores multiple lines of text.
17 Because Boolean Values False and True behave like the values 0 and 1, respectively. So Boolean
type is a subtype of plain integers
18 Loops are iteration constructs in Python. Iteration means repetition of a set of statements
depending upon a condition test.
19 Three Types of Sequences are supported in python
20 a. 3.0 b. 1
21 String Slice is a part of a string containing some contiguous characters from the string. It is
accessed from the string by providing a range in ― ” [ ] ” brackets i.e. S [n:m].
22 a.It guides data flow through the computer’s memory,ALU and input or output.
b. binary language
c. microprocessor
d. RAM
e. Input-Process-Output Cycle
23 a. while loop
b. syntax : for variable in range(start , stop):
statements
c. for i in range(100,0,-3):
print(i)
d. break and continue
e. The range() function returns a sequence of numbers, starting from 0 by default, and
increments by 1 (by default), and ends at a specified number.
its syntax is range(start, stop, step)
24 (1024)4 bytes or 1012bytes
25 Functions of OS:
Process Management, Memory Management, File Management or Device Management
OR
17 5
26 (X+Y)’ = X’Y’
(X.Y)’ = X’+Y’
27 178
OR
28 -2
6561
29 The name should not start with numbers or digit.
It should not have a keyword such as if,else,for,while,etc.
It should not have blank spaces in it
It should not contain any special symbol like #,@, etc
30 Output: Hari , you are 18 now but You will be 19 next year
31 Escape characters are those non-graphical characters that are not displayed on the screen.
Hello
World
32 A statement is an instruction that the Python interpreter can execute. We have only seen the
assignment statement so far. Some other kinds of statements that we‘ll see shortly are while
statements, forstatements, if statements, and import statements. (There are other kinds too!)
An expression is a combination of values, variables, operators, and calls to functions. Expressions
need to be evaluated. If you ask Python to print an expression, the interpreter evaluates the
expression and displays the result.
33 String do not support item assignment so we cannot change individual letter of a string.
Example:
a1=”Ram”
a1[0]=’S’
print(a1)
Here the output will give an ERROR
But
a1=”Ram”
a1=”Test”
print(a1)
Here the output is Test
34
Interpreter Compiler
Scans the entire program and translates it as a
Translates program one statement at a time.
whole into machine code.
Interpreters usually take less amount of time Compilers usually take a large amount of time
to analyze the source code. However, the to analyze the source code. However, the
overall execution time is comparatively slower overall execution time is comparatively faster
than compilers. than interpreters.
No Object Code is generated, hence are Generates Object Code which further requires
memory efficient. linking, hence requires more memory.
Programming languages like JavaScript, Programming languages like C, C++, Java use
Python, Ruby use interpreters. compilers.
35 n=int(input(“Enter a number=”))
c=0
while n>0:
c=c+1
n=n//10
print(“The total number of digits are=”,c)
36
Interactive Mode Script Mode
It is a way of executing a In the script mode, the Python program is
Python program in which written in a file. Python interpreter reads
statements are written in the file and then executes it and provides
command prompt and result is the desired result. The program is
obtained on the same. compiled in the command prompt,
The interactive mode is more
suitable for writing very short Script mode is more suitable for writing
programs. long programs.
Editing of code can be done but Editing of code can be easily done in
it is a tedious task. script mode.
We get output for every single
line of code in interactive mode
i.e. result is obtained after In script mode entire program is first
execution of each line of code. compiled and then executed.
Code cannot be saved and Code can be saved and can be used in
used in the future. the future.
It is more preferred by It is more preferred by experts. Beginners
beginners. to use script mode.
36 n=int(input(“Enter value of n:”))
print(“n^2:”,n*n)
print(“n^3:”,n*n*n)
print(“n^4:,n*n*n*n)
37 i=65
while i<=68:
j=65
while j<=i:
print(chr(j),end=” “)
j=j+1
print(()
i=i+1
OR
Computer Science
eniSrtpo
38 # Python program to check if the number is an Armstrong number or
not
# take input from the user
num = int(input("Enter a number: "))
# initialize sum
sum = 0
# find the sum of the cube of each digit
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
# display the result
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
39
1. The data is accepted by the input unit. It is given by
the user. It is then converted into binary form for the
computer to read it.
2. The information is then sent to the memory unit for
storage and processing.
3. The required data, that needs to be processed is
accessed by the CPU. It is accessed from the primary
storage. The arithmetic and logical operations are then
performed on the data. The control unit schedules all
the activities for the smooth working of the computer.
4. The data is then sent to the storage unit. It is used for
storing or further processing purposes.
5. Then the output unit receives the final processed
output.
40. R.H.S. = (X + Y)(X + Z)
= XX + XZ + XY + YZ
= X + XZ + XY + YZ (XX = X Indempotence law)
= X + XY + XZ + YZ
= X(1 + Y) + Z(X + Y)
= X.1 + Z(X + Y) (1 + Y = 1 property of 0 and 1)
= X + XZ + YZ) (X . 1 = X property of 0 and 1)
= X(1 + Z) + YZ
= X.1 + YZ (1 + Z = 1 property of 0 and 1)
= X.1 + YZ (X . 1 = X property of 0 and 1)
= L.H.S. Hence proved
OR
n=int(input("Enter number:"))
temp=n
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
if(temp==rev):
print("The number is a palindrome!")
else:
print("The number isn't a palindrome!")