@lakshayarora7/

FunnyIllfatedNarwhale

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.4645305714655117","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"IyMgUHJvZ3JhbSB0byBkZXRlcm1pbmUgd2hldGhlciBhIGdpdmVuIHllYXIgaXMgYSBsZWFwIHllYXIgb3Igbm90LiBBIGxlYXAgeWVhciBpcyBvbmUgd2l0aCAyOSBkYXlzIGluIHRoZSBtb250aCBvZiBGZWJydWFyeSwgYW5kIG1hdGhlbWF0aWNhbGx5LCBpdCBpcyBhIG11bHRpcGxlIG9mIDQwMCBvciAxMDAgb3IgNC4NCg0KIyBUYWtlIHRoZSBpbnB1dCBmcm9tIHRoZSB1c2VyDQp5ZWFyID0gaW50KGlucHV0KCJFbnRlciBhbiB5ZWFyOiAiKSkNCmlzQWxlYXBZZWFyID0gRmFsc2UgIyB0aGlzIHZhcmlhYmxlIHNlcnZlcyBhcyBhIGZsYWcgaW4gdGhlIHByb2dyYW0gaS5lLiBpdHMgdmFsdWUgd2lsbCBiZSBlaXRoZXIgdHJ1ZSBvciBmYWxzZSBiYXNlZCBvbiBjb25kaXRpb25zLCBhbmQgYXQgc29tZSBwb2ludCBpbiB0aGUgcHJvZ3JhbSwgdGhpcyBmbGFnIHdpbGwgZGVjaWRlIHRoZSBmbG93IG9mIHRoZSBwcm9ncmFtIGkuZS4gd2hpY2ggc3RhdGVtZW50cyB0byBleGVjdXRlIGFuZCB3aGljaCBvbmVzIHRvIHNraXAgYWNjb3JkaW5nIHRvIGl0cyB2YWx1ZS4gU2luY2UgUHl0aG9uIGlzIGFuIGludGVycHJldGVkIGxhbmd1YWdlLCBhbnkgdmFyaWFibGUgd2UgdXNlIGluc2lkZSB0aGUgcHJvZ3JhbSBuZWVkcyB0byBiZSBkZWNsYXJlZCBiZWZvcmVoYW5kIHNvIHRoYXQgdGhlIGludGVycHJldGVyIGtub3dzIHRoYXQgdGhlcmUgaXMgYSB2YXJpYWJsZSBieSB0aGlzIG5hbWUuIFdlIGNhbiBpbml0aWFsaXplIGl0IHdpdGggdGhlIHdyb25nIHZhbHVlLCBpdCBqdXN0IG5lZWRzIHRvIGJlIGluIHRoZSBtZW1vcnkgc28gdGhhdCB0aGUgaW50ZXJwcmV0ZXIgY2FuIHJlY29nbml6ZSBpdC4gV2UgY2FuIGRlY2xhcmUgdGhpcyB2YXJpYWJsZSBhbnl3aGVyZSBiZWZvcmUgaXRzIHVzZSwgYnV0IHRoZSBjb252ZW50aW9uIGlzIHRvIGRlY2xhcmUgdmFyaWFibGVzIGF0IHRoZSB0b3AsIGJlZm9yZSB0aGUgYWN0dWFsIGxvZ2ljLCBmb3IgZWFzeSBjb2RlIHdhbGt0aHJvdWdoLg0KDQojIERldGVybWluZSB3aGV0aGVyIHRoZSBzdXBwbGllZCB5ZWFyIGlzIGEgbGVhcCB5ZWFyIG9yIG5vdA0KaWYgeWVhciAlIDQwMCA9PSAwOg0KICAgIGlzQWxlYXBZZWFyID0gVHJ1ZQ0KZWxpZiB5ZWFyICUgMTAwID09IDA6DQogICAgaXNBbGVhcFllYXIgPSBUcnVlDQplbGlmIHllYXIgJSA0ID09IDA6DQogICAgaXNBbGVhcFllYXIgPSBUcnVlDQplbHNlOg0KICAgIGlzQUxlYXBZZWFyID0gRmFsc2UNCg0KIyBQcmludGluZyB0aGUgcmVzdWx0DQppZiBpc0FsZWFwWWVhcjoNCiAgICBwcmludCh5ZWFyLCAiaXMgYSBsZWFwIHllYXIuIikNCmVsc2U6DQogICAgcHJpbnQoeWVhciwgImlzIG5vdCBhIGxlYXAgeWVhci4iKQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
## Program to determine whether a given year is a leap year or not. A leap year is one with 29 days in the month of February, and mathematically, it is a multiple of 400 or 100 or 4.

# Take the input from the user
year = int(input("Enter an year: "))
isAleapYear = False # this variable serves as a flag in the program i.e. its value will be either true or false based on conditions, and at some point in the program, this flag will decide the flow of the program i.e. which statements to execute and which ones to skip according to its value. Since Python is an interpreted language, any variable we use inside the program needs to be declared beforehand so that the interpreter knows that there is a variable by this name. We can initialize it with the wrong value, it just needs to be in the memory so that the interpreter can recognize it. We can declare this variable anywhere before its use, but the convention is to declare variables at the top, before the actual logic, for easy code walkthrough.

# Determine whether the supplied year is a leap year or not
if year % 400 == 0:
    isAleapYear = True
elif year % 100 == 0:
    isAleapYear = True
elif year % 4 == 0:
    isAleapYear = True
else:
    isALeapYear = False

# Printing the result
if isAleapYear:
    print(year, "is a leap year.")
else:
    print(year, "is not a leap year.")