py coding 3/26/22

03/06/22

 1>Write a code to print all the values from 1 to 100 but skip the numbers those are divisable by 3 and 5.

i=1
a=1
while i<=100:
if((a%3 and a%5) ==0):
a=a+1
else:
print(a)
a=a+1
i = i+1  
using while loop
2>Write a code for a pattern like -----                                         # # # #
                                                                                # # # #
                                                                                # # # #
                                                                                # # # #
i=1
a ='#'
while i<=4:
print(a,end="")
j=1
while j<=4:
print(a,end="")
j=j+1
i=i+1
print()
28/03/2022
3>Write a code to print all the values from 1 to 100 and skip the numbers those are divisable by 3 and 5.
for i in range(1,100,1) :
if ((i%3 and i%5) == 0):
i = i+1
else:
print(i)
i= i +1
using for loop.
4>Print the perfect square between two range.Range will be user input.
a=int (input('a ='));
b=int (input('b ='));
for i in range(1,b):
if (i**2<=b and i**2>=a):
print(i**2)
29/03/2022
5>Check it's a prime number or not.
x = int(input("Enter you num\n"))
if x==1:
print('its not a prime number')
elif x==2 or x%2 ==1:
print('its a prime number')
else:
print('its not a prime number')

Comments