November 16 from 15:00 to 16:00
Enter a 4-digit year to display whether it is a leap year
Create a gram. (Already done) Repeat input/judgment display until end is entered. A function is used to determine the leap year. How should the function part and end part be written?
I am a beginner and spend time, but I can't solve it.
year = input ("Please enter the year!") year = int (year) if year% 400 == 0: print ("閏年") elif year% 100 == 0: print ("average") elif year% 4 == 0: print ("閏年") else: print ("average") Code
Answer # 1
year = "" def judge (year): if year% 400 == 0: print ("leap year") elif year% 100 == 0: print ("normal year") elif year% 4 == 0: print ("leap year") else: print ("normal") while year! = "end": year = input ("Please enter the year!") if year! = "end": judge (int (year))
Is this the case? I don't think it's very good code.
- python - i want to define a function using a csv file
- please explain the function using the python dictionary
- python - i want to learn using my own error function in tensorflow
- can multiple file io by built-in function open using multithreading in python be expected to be faster?
- i don't understand the description when using lambda for the key of the sort method of python
- python - i want to know how this function is recursively defined
- to get the same output without using python dict
- image recognition using python beginner pyautogui is not possible
- python - split function in pandas dataframe
- [python] data preprocessing using pandas (deletion of multiple columns)
- python - get right-justified dataframe with split function of pandas dataframe
- i want to do something like a function pointer in a class in python
- python - when using pil, an error screen is displayed
- [python3] i want to enter the contents (name) of the qr code using a barcode reader
- python - probability prediction using multiple time series data
- [python] does the function exp work for matrices?
- file reading and calculation using python
- i want to get a mac table using snmp in python
- how to store in dict using python for loop
- python - writing data to continuous excel using a text box
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- python - you may need to restart the kernel to use updated packages error
- python 3x - typeerror: 'method' object is not subscriptable
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - unresolved reference comes out in kotlin