What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-03 05:15:16
random choice without random module
# First let's make a function that makes a random number def randint(a, b): "Return random integer in range [a, b], including both end points." return a + randbelow(b - a + 1) def randbelow(n): "Return a random int in the ran... Add solution -
Python 2022-02-17 21:30:11
ValueError: I/O operation on closed file.
ValueError: I/O operation on closed file. The Above error may ossour because, you are writing to the file When it is closed ** To Solve this error ** >>> Make sure that your file.write statement is in the >>> 'with open('textFile.t... Add solution -
Python 2022-02-02 18:56:21
python event start from file funcion
from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler class WatchPendingHandler(FileSystemEventHandler): ''' Run a handler for every file added to the pending dir This class also handles what I call a bug in ... Add solution -
Python 2022-01-30 19:31:20
how to convert dollars to rupees and rs to dollar in python
print('hello welcome to converter of rs to dollar and dollar to rs') print() carry_on = True while carry_on: try: ask = int(input('write what do you want to do find? for finding dollar to rs type "1" or to find rs to dollar write... Add solution -
Python 2022-01-27 22:05:02
add 3 years to a given date in python code
import datetime from datetime import date def addYears(d, years): try: #Return same day of the current year return d.replace(year = d.year + years) except ValueError: #If not same day, it will return other, i.e. February 29 to Mar... Add solution -
Python 2022-01-23 05:00:14
cross_val_score scoring parameters types
>>> from sklearn import svm, cross_validation, datasets >>> iris = datasets.load_iris() >>> X, y = iris.data, iris.target >>> model = svm.SVC() >>> cross_validation.cross_val_score(model, X, y, scoring='wrong_c... Add solution -
Python 2022-01-22 04:40:02
python check if input() gives error
try: # Note: Python 2.x users should use raw_input, the equivalent of 3.x's input age = int(input("Please enter your age: ")) except ValueError: print("Sorry, I didn't understand that.") else: if age >= 18: print(... Add solution