Skip to content

Commit 48d0059

Browse files
committed
update
1 parent ef19478 commit 48d0059

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

Hackerrank/Write a Function.py

+43
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<<<<<<< HEAD
12
# We add a Leap Day on February 29, almost every four years. The leap day is an extra, or intercalary day and we add it to the shortest month of the year, February.
23
# In the Gregorian calendar three criteria must be taken into account to identify leap years:
34
#
@@ -38,4 +39,46 @@ def is_leap(year):
3839
return leap
3940

4041
year = int(input())
42+
=======
43+
# We add a Leap Day on February 29, almost every four years. The leap day is an extra, or intercalary day and we add it to the shortest month of the year, February.
44+
# In the Gregorian calendar three criteria must be taken into account to identify leap years:
45+
#
46+
# The year can be evenly divided by 4, is a leap year, unless:
47+
# The year can be evenly divided by 100, it is NOT a leap year, unless:
48+
# The year is also evenly divisible by 400. Then it is a leap year.
49+
# This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.Source
50+
#
51+
# Task
52+
# You are given the year, and you have to write a function to check if the year is leap or not.
53+
#
54+
# Note that you have to complete the function and remaining code is given as template.
55+
#
56+
# Input Format
57+
#
58+
# Read y, the year that needs to be checked.
59+
#
60+
# Constraints
61+
#
62+
#
63+
# Output Format
64+
#
65+
# Output is taken care of by the template. Your function must return a boolean value (True/False)
66+
#
67+
# Sample Input 0
68+
#
69+
# 1990
70+
# Sample Output 0
71+
#
72+
# False
73+
# Explanation 0
74+
#
75+
# 1990 is not a multiple of 4 hence it's not a leap year.
76+
def is_leap(year):
77+
leap = False
78+
if(year%4==0 and not (year%100==0) or year%400==0):
79+
leap = True
80+
return leap
81+
82+
year = int(input())
83+
>>>>>>> 97a7e02 (update)
4184
print(is_leap(year))

Scripts/renamer.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## script to rename all files in a directory from a list of file names
2+
3+
import os
4+
5+
# list of new filenames
6+
new_filenames = ['new_file1.txt', 'new_file2.txt', 'new_file3.txt']
7+
8+
# directory containing the files to be renamed
9+
directory = 'path/to/directory'
10+
11+
# get a list of all files in the directory
12+
files = os.listdir(directory)
13+
14+
# rename each file
15+
for i, file in enumerate(files):
16+
os.rename(os.path.join(directory, file), os.path.join(directory, new_filenames[i]))

0 commit comments

Comments
 (0)