0% found this document useful (0 votes)
10 views5 pages

Phython Practice Questions All 3 Lec

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)
10 views5 pages

Phython Practice Questions All 3 Lec

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/ 5

PHYTHON PRACTICE :

NORMAL
ARITHMETIC OPERATORS :- USE FOR MATHEMATICAL OPERATIONS ->

Operator Description Example (a = 10, b = 3) Output


+ Addition a + b 13
- Subtraction a - b 7
* Multiplication a * b 30
/ Division a / b 3.333
// Floor Division a // b 3
% Modulus (Remainder) a % b 1
** Exponentiation a ** b 1000

Code : -
# addition (a and b are variable )
a = any value
b = any value
c=a+b
print("The sum is", c)
QUESTIONS :-
ADDITION OF TWO NUMBERS ?
PROGRAM FOR QUADRATIC EQUATION ?
PROGRAM FOR AREAM OF CIRCLE ?
FIND THE REMAINDER OF NUMBER ?
SWAP TWO NUMBERS WITHOUT USING A THIRD VALUE ?
MAKE A SIMPLE CALCULATOR ? USING INPUT STATEMENT ?
FOR BIOINFORMATICS AND BIOTECHNOLOGIST :-
CALCULATE GC COUNT ? ( A+T/TOTAL SEQ*100)
TRANSCRIBE DNA to RNA? (SEQ RELACED BY A-T AND G-C)(.replace is use )?
COUNT NUCLEOTIDE IN DNA SEQUENCE ?
COMPUTE MELTING TEMRATURE OF DNA SEQUENCE ? (T=4(G+C)+2(A+T))
FOR DATA ANALYST :- numbers =[ 1, 2, 3]  this is how you can put sets
CALCULATE MEAN ?(2 ,5,6 7,10)
COUNT OCCURANCE OF A VALUE IN LIST ?(2,3,3,3,4,5,5,)( numbers.count(value))
FIND MAXIMUM AND MINIMUM IN LIST? (2,10,13,1,4,19)(a=max(num),same as min)

IF AND ELSE :

COMPARISON OPERATORS :

Operator Description Example (a = 10, b = 3) Output


== Equal to a == b False
!= Not equal to a != b True
> Greater than a > b True
< Less than a < b False
>= Greater than or equal to a >= b True
<= Less than or equal to a <= b False

Logical Operators

Used to combine conditional statements.

Example (x = True, y =
Operator Description Output
False)
Returns True if both conditions are
and x and y False
True
Returns True if at least one condition is
or x or y True
True
not Reverses the condition not x False

CODE :-
IF ( STATEMENT LIKE a==0) : ( ELIF ) FOR 3 VALUES
PRINT(“EXPRESSION”)
ELSE :
PRINT(“EXPRESSION”)
QUESTION :
CHECK THE NUMBERS IS POSITIVE , ZERO,NEGATIVE?
PROGRAM TO IDENTIFY ODD AND EVEN NUMBER ?
FIND THE LARGEST NUMBER BETWEEN 2 NUMBERS ?
CHECK IF YEAR IS A LEAP YEAR ?
FING THE LARGEST OF 3 NUMBERS ?(BY USING INPUT STATEMENT)
CHECK IF A CHARACTER IS A VOWEL OF CONSTANT ? (aeiou)
Use this (char = input("Enter a character: ").lower())
(.lower is for to covert all letter in lowercase and .upper() is for uppercase)

CHECK IF A NO. IS DIVISIBLE BY 5 AND 11?


PROGRAM FOR GRADE CALCULATION ?
FOR BIOINFORMATICS AND BIOTECHNOLOGIST : -
FIND GC CONTENT OF SEQUENCE ( HIGH LOW AND NORMAL )
SAME AS IN ABOVE JUST PROVIDE IF ELSE .

CHECK IF A SEQUENCE CONTAINS A SPECIFIC MOTIFS ( SEQ AND MOTIFS ARE 2 VARIABLE )
CHECK IF A DNA SEQUENCE IS A SUBSEQUENCE OF ANOTHER ?( if seq2 in seq1:)

WHILE LOOP ( USE ALL OPERATORS ) : UNDER STAND THE OPERATORS

Assignment Operators :

Used to assign values to variables.

Operator Description Example (x = 5) Equivalent to


= Assign x = 5 x = 5
+= Add and assign x += 3 x = x + 3
-= Subtract and assign x -= 2 x = x - 2
*= Multiply and assign x *= 4 x = x * 4
Operator Description Example (x = 5) Equivalent to
/= Divide and assign x /= 2 x = x / 2
//= Floor divide and assign x //= 2 x = x // 2
%= Modulus and assign x %= 3 x = x % 3
**= Exponentiate and assign x **= 2 x = x ** 2
&= Bitwise AND and assign x &= 2 x = x & 2
` =` Bitwise OR and assign `x
^= Bitwise XOR and assign x ^= 2 x = x ^ 2
<<= Left shift and assign x <<= 2 x = x << 2
>>= Right shift and assign x >>= 2 x = x >> 2

Identity Operators :

Used to compare the memory location of two objects.

Example (a = 10, b =
Operator Description Output
10)
is Returns True if both refer to the same object a is b True
Returns True if they do not refer to the same
is not a is not b False
object

Membership Operators :

Used to check whether a value is present in a sequence (list, tuple, string, etc.).

Operator Description Example (x = [1, 2, 3]) Output


in Returns True if a value exists in a sequence 2 in x True
not in Returns True if a value does not exist 4 not in x True
CODE :
Initilization i=1
While (condition ) while i<=5 :
Statement print(“welcome”)
i=i+1
increment /decrement print(“end”)

QUESTION: ( BERFORE SOLVIING UNDERSTAND THE ALL OPERATORS )


PRINT NO. FROM 1 TO 10?
WRITE A STATE THE PRINCIPLE AMOUNT,NO.OF YEARSAND RATE OF INTREST ROM USER AND
CALCULATE SIMPLE INTREST FOR 3 TIMES ?
( FORMULA = P*r*t/100)
WRITE A PROGRAM PRINT NO. UNTIL USER ENTER 0?
PROGRAM ACCEPT 2 NO. AND CALCULATE OF 1 NO. RAISED TO ANAOTHER ?
FIND THE FACTORIAL OF NUMBER ?
CHECK IF NO. IS PRIME ?
FOR BIOINFORMATICS :
COUNT ‘A’ IN DNA SEQUENCE ?
ANS ------
seq = input("Enter a DNA sequence: ").upper()
count = 0
i=0
while i < len(seq):
if seq[i] == 'A':
count += 1
i += 1
print("Count of A's:", count)
COUNT G?
CAOUNT T?
COUNT C?

You might also like