Practical Test
Practical Test
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
.
.
.
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)