0% found this document useful (0 votes)
11 views

Practical Test

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Practical Test

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical Hack

Course: Python and Programming fundamentals (50 Marks.)

Do whatever problems you know first. No need to solve in order.


Choose one of these Basic or Advanced and solve ...
You may use shell to try stuff. You can refer to intellitrak_index. Cannot google. Cannot look
at old programs.
Basic (do all 5)
1. Write a function to compute the final velocity of a train which is moving in a straight
direction. The final velocity is computed using the formula
fv2 = iv2 + 2as
where a is the acceleration, iv is the initial velocity and s is the distance it travels.

or (for smaller kids)

Write a function to compute the areaCircle


where area = pi r2

Call the function correctly and print the result.


(Functions should not print or accept input. Parameters should be passed, and results
should be returned)

2. From the random module import random. Now generate a random number between 1
and 10. Ask user to guess the number. Tell user if he guessed correctly or if his guess
is too high or too small. You have to give him 4 tries.

3. Accept 6 numbers and print the number with the most number of digits. If two or
more numbers have the same number of digits the program may print any one of
them.

4. Using a for loop,print of table of powers of X, where X ranges from 1 to 10. For each
value X, print the quantityX, X2 and X3. Use tab characters in your print statement to
make the values line up nicely.(if you don’t know for loop, you can use while loop)

x x2 x3
1 1 1
2 4 8
3 9 27
.
.
.

Email: [email protected] on web at: http://www.intellitrak.in


Practical Hack
5. Write a series of python statement that will import the math module, read a number
from the user that represents an angle given in radians, and then print s the sine and
cosine for the given angle

Advanced (do any 4)

1. Accept 6 numbers and find the sum of the first and the last numbers. Use
a loop to accept.

2. Accept a number and find the sum of all the digits. Use Loops.Number
can be of any number of digits.

3. Accept some digits in a loop (till user enters -1, break when user enters -
1) and display the full number in the end. Eg: if the digits are 5,3,2,9 and
-1 then the number should be 9235. (You cannot accept the number as a
string)

4. Write a function to find if a passed number is a Prime number.


Call the function correctly and print the result.

(Functions should not print or accept input. Parameters should be passed,


and results should be returned)

5. From the random module import random. Now generate a random


number between 1 and 10. Ask user to guess the number. Tell user if he
guessed correctly or if his guess is too high or too small. You have to give
him 4 tries.

Email: [email protected] on web at: http://www.intellitrak.in

You might also like