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

Pyhon_assignment_10_For_classroom_practice

Uploaded by

Shubham Chaubey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Pyhon_assignment_10_For_classroom_practice

Uploaded by

Shubham Chaubey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

09/08/2024, 17:50 Pyhon_assignment_10_For_classroom_practice

In [1]: #Q1
for i in range (1,6):
n1= eval(input('enter a number:'))
if n1%2==0:
print('number is evan ')

else:
print('number is odd')

#print(f'{n1} is {i}')

number is odd
number is odd
number is evan
number is evan
number is evan

In [2]: #Q2
for i in range (1,11):
#print(7 * i)
print(f"7 X {i} = {7*i}")

7 X 1 = 7
7 X 2 = 14
7 X 3 = 21
7 X 4 = 28
7 X 5 = 35
7 X 6 = 42
7 X 7 = 49
7 X 8 = 56
7 X 9 = 63
7 X 10 = 70

In [3]: #Q3
num = eval (input('Enter number'))
for i in range (1,num+1):
if num % i ==0:
print(i)

1
2
4
5
10
20

In [4]: #Q4
summ = 0
for i in range (1,11):
summ = summ +i
print(summ)

file:///C:/Users/Shubham/Downloads/Pyhon_assignment_10_For_classroom_practice.html 1/3
09/08/2024, 17:50 Pyhon_assignment_10_For_classroom_practice

1
3
6
10
15
21
28
36
45
55

In [5]: #Q5 Average of first 10 natural number


summ = 0
for i in range (1,11):
summ = summ +i
print(summ/10)

0.1
0.3
0.6
1.0
1.5
2.1
2.8
3.6
4.5
5.5

In [6]: #Q6
summ = 0
def summm1():
global summ
for i in range (1,11):
summ = summ +i
return(summ)
summ = summm1()
#summm1()
print(summ/10)

0.1

In [7]: #Q7
count = 0
num = eval (input('Enter number'))
for i in range (1,num+1):
if num % i ==0:
#print(i)
count=count+1
print('The number of devistion are :', count)

The number of devistion are : 2

In [8]: #Q8
summ , count= 0 , 0
num = eval (input('Enter number'))
for i in range (1,num+1):
if num % i ==0:
#print(i)
count=count+1
print(f'All divition of {num} :{i}')
summ = summ + i

file:///C:/Users/Shubham/Downloads/Pyhon_assignment_10_For_classroom_practice.html 2/3
09/08/2024, 17:50 Pyhon_assignment_10_For_classroom_practice

print('The number of devistion are :', count)


print('The sum of all count number is :',summ)

All divition of 50 :1
All divition of 50 :2
All divition of 50 :5
All divition of 50 :10
All divition of 50 :25
All divition of 50 :50
The number of devistion are : 6
The sum of all count number is : 93

In [9]: #Q9
import random

for i in range (1,4):


number = random.randint(1,10)
print('Random number is :', number)
num1=eval(input('Enter a number1 :'))

if number == num1:
print ('You Won')

else:
print('Loss')

Random number is : 5
Loss
Random number is : 5
Loss
Random number is : 9
You Won

In [18]: import random

# Number of chances
chances = 3

for i in range(chances):
number = random.randint(1, 10)

num1 = eval(input('Enter a number between 1 and 10: '))

if number == num1:
print('You Won!')
break
else:

remaining_chances = chances - (i + 1)
if remaining_chances > 0:
print(f'Loss. You have {remaining_chances} chance(s) left.')
else:
print('Loss. Try after 24 hours.')

Loss. You have 2 chance(s) left.


Loss. You have 1 chance(s) left.
Loss. Try after 24 hours.

In [ ]:

file:///C:/Users/Shubham/Downloads/Pyhon_assignment_10_For_classroom_practice.html 3/3

You might also like