반응형 <개인공부> - IT/[Python]39 Python in operator (Regular Expression Matching) Nowadays I really focus on preparing coding interview. I am going to briefly summarize and post what I learn and study. text = "aa" pattern = "a" # Whether pattern is null or not # if it is null return False if not pattern: return not text # Input text is not null # Pattern has the same character or '.' first_match = bool(text) and pattern[0] in {text[0], '.'} if len(pattern) >= 2 and pattern[1].. 2019. 1. 10. What does if __name__ == “__main__”: do? 궁금해서 찾아보았는데 과제하는데 도움이 될 것 같아서 공부삼아 기록한다. When your script is run by passing it as a command to the Python interpreter, python myscript.py all of the code that is at indentation level 0 gets executed. Functions and classes that are defined are, well, defined, but none of their code gets run. Unlike other languages, there's no main() function that gets run automatically - the main() function is im.. 2018. 9. 15. Python Multiple return values (Tuple, Dict) # Question:# Write a program that accepts a sentence and calculate the number #of letters and digits.# Suppose the following input is supplied to the program:# hello world! 123# Then, the output should be:# LETTERS 10# DIGITS 3 [Tuple 이용] def countingStr(sentence): countNum = 0 countChar = 0 for i in range(len(sentence)): if((65 2018. 8. 23. List 자료형의 Join함수 사용하기 Question:Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,between 2000 and 3200 (both included).The numbers obtained should be printed in a comma-separated sequence on a single line. def divisibleSevenNotDivisibleFive(): listOfNumber = "" # Range: 2000 ~ 3200 for i in range(2000, 3201): if((i % 7 == 0) and (i % 5 != 0)): listOfNumber = listOfN.. 2018. 8. 21. 이전 1 ··· 5 6 7 8 9 10 다음 반응형