hi buddy
This commit is contained in:
2
stuff/loops/num1.py
Normal file
2
stuff/loops/num1.py
Normal file
@@ -0,0 +1,2 @@
|
||||
for i in range (11):
|
||||
print(i, end=" ")
|
||||
3
stuff/loops/num10.py
Normal file
3
stuff/loops/num10.py
Normal file
@@ -0,0 +1,3 @@
|
||||
num = int(input("Enter a number: "))
|
||||
|
||||
print(str(num)[::-1])
|
||||
4
stuff/loops/num2.py
Normal file
4
stuff/loops/num2.py
Normal file
@@ -0,0 +1,4 @@
|
||||
n = int(input("Enter a number: "))
|
||||
|
||||
b = sum(range(1, n+1))
|
||||
print(b)
|
||||
5
stuff/loops/num3.py
Normal file
5
stuff/loops/num3.py
Normal file
@@ -0,0 +1,5 @@
|
||||
a = int(input("Enter a number: "))
|
||||
c = 1
|
||||
while (c <= 10):
|
||||
print(a * c)
|
||||
c += 1
|
||||
7
stuff/loops/num4.py
Normal file
7
stuff/loops/num4.py
Normal file
@@ -0,0 +1,7 @@
|
||||
a = int(input("Enter a number: "))
|
||||
b = a * 5
|
||||
c = b % 2
|
||||
if (c != 0):
|
||||
print("Not divisible by 5")
|
||||
else:
|
||||
print("Divisible by 5")
|
||||
7
stuff/loops/num5.py
Normal file
7
stuff/loops/num5.py
Normal file
@@ -0,0 +1,7 @@
|
||||
a = int(input("Enter a number: "))
|
||||
count = 0
|
||||
|
||||
while (a > 0):
|
||||
count = count + 1
|
||||
a = a // 10
|
||||
print(count)
|
||||
2
stuff/loops/num6.py
Normal file
2
stuff/loops/num6.py
Normal file
@@ -0,0 +1,2 @@
|
||||
for i in range(-10,0):
|
||||
print(i, end=" ")
|
||||
9
stuff/loops/num7.py
Normal file
9
stuff/loops/num7.py
Normal file
@@ -0,0 +1,9 @@
|
||||
tg = int(input("Enter a number: "))
|
||||
|
||||
for number in range(1,tg+1):
|
||||
if number > 1:
|
||||
for i in range(2, number):
|
||||
if (number%i) == 0:
|
||||
break
|
||||
else:
|
||||
print(number)
|
||||
11
stuff/loops/num8.py
Normal file
11
stuff/loops/num8.py
Normal file
@@ -0,0 +1,11 @@
|
||||
a = 100
|
||||
|
||||
n1, n2 = 0, 1
|
||||
count = 0
|
||||
|
||||
while count < a:
|
||||
print(n1)
|
||||
nth = n1 + n2
|
||||
n1 = n2
|
||||
n2 = nth
|
||||
count += 1
|
||||
5
stuff/loops/num9.py
Normal file
5
stuff/loops/num9.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import math
|
||||
|
||||
a = int(input("Enter a number: "))
|
||||
b = math.factorial(a)
|
||||
print(b)
|
||||
Reference in New Issue
Block a user