0% found this document useful (0 votes)
6 views3 pages

Python Programs

Uploaded by

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

Python Programs

Uploaded by

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

n = int(input(print("Enter n")))

for i in range(n):
for j in range(2*n):
if i + j == n-1 or i == n-1 or j - i == n-1:
print("*", end="")
else:
print(end=" ")
print()

n = int(input(print("Enter n")))
str_n = str(n)

# Initializing result as number and string


sums = n
sum_str = str(n)

# Adding remaining terms


for i in range(1, n):

# Concatenating the string making n, nn, nnn...


sum_str = sum_str + str_n

# Before adding converting back to inte


ger
sums = sums + int(sum_str)

print(sums)

import math
# Returns true if n can be written as x^y
def isPower(n) :
if (n==1) :
return True
# Try all numbers from 2 to sqrt(n) as base
for x in range(2,(int)(math.sqrt(n))+1) :
y = 2
p = (int)(math.pow(x, y))
# Keep increasing y while power 'p' is smaller
# than n.
while (p<=n and p>0) :
if (p==n) :
return True

y = y + 1
p = math.pow(x, y)

return False
# Driver Program
i = int(input(print("Enter n")))
max = int(input(print("Enter max")))
min = int(input(print("Enter min")))
for i in range(min,max ) :
if (isPower(i)) :
print(i,end=" ")

import calendar
m = int(input("Enter month"))
d = int(input("Ënter year"))

START_YEAR = 1900
END_YEAR = 2020
CALOBJ = calendar.Calendar()
LUCKY = 0
for year in range(START_YEAR, END_YEAR):
for month in range(1, 13):
for day in CALOBJ.itermonthdays2(year, month)
:
if day[0] == 13 and day[1] == 4:
LUCKY = 1

if (LUCKY == 1):
print("TRUE")
else:
print("FALSE")

You might also like