-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14_Practice_Loops.py
More file actions
76 lines (64 loc) · 1.56 KB
/
14_Practice_Loops.py
File metadata and controls
76 lines (64 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Q1. Table using loop
# a = int(input("Enter your number: "))
# for i in range(1,11,1):
# mul = a * i
# print(a,"*",i,"=" ,mul)
# Q2. To greet all person in a list whose name starts with R
# list = ["Rohan" , "Ram" , "Sohan" , "Rishav" , "Tony"]
# for item in list:
# store = item
# for item in item:
# if(item == "R"):
# print("Good Moring:",store)
# Q3. Find a number is prime or not
# a = int(input("Enter your number: "))
# count = 0
# for i in range(2,a):
# if(a%i == 0):
# count+=1
# if(count < 2):
# print("Prime Number")
# else:
# print("Not Prime")
# Q4. Sum of first n natural numbers
# a = int(input("Enter your number: "))
# sum = 0
# for i in range(0,a+1,1):
# sum+=i
# print(sum)
# Q5. Calculate the factorial
# a = int(input("Enter your number: "))
# fact = 1
# for i in range(1,a+1,1):
# fact = fact * i
# print(fact)
# Q6. Print table in reverse order
# a = int(input("Enter your number: "))
# for i in range(10,0,-1):
# print(a, "*", i, "=", a*i)
# Q7. Star Pattern
'''
*
***
*****
'''
# a = int(input("Enter your number: "))
# for i in range(1, a+1):
# print(" "* (2*i-1), end="")
# print("*"* i, end="")
# print("\n")
# Q8 . Star Pattern
'''
* * *
* *
* * *
'''
a = int(input("Enter your number: "))
for i in range(1, a+1):
if(i == 1 or i == a):
print("*" * a, end="")
else:
print("*", end="")
print(" "* (a - 2), end="")
print("*", end="")
print("")