Skip to content
Advertisement

Tag: function

Explanation about def rewind(f): f.seek(0)

i was reading a book and there was a code which had a this line in it and this is a line that i can’t understand can you please explain me what is going on ? -im using python 2.7 thanks for your time Answer I would try reading this post on tutorials point. The top of the article should

Syllable Count In Python

I need to write a function that will read syllables in a word (for example, HAIRY is 2 syllables). I have my code shown on the bottom and I’m confident it works in most cases, because it works with every other test I’ve done, but not with “HAIRY” where it only reads as 1 syllable. TEST Expected: 2 Received: 1

Conversion of string to upper case without inbuilt methods

I am trying to perform conversion from a lowercase to uppercase on a string without using any inbuilt functions (other than ord() and char()). Following the logic presented on a different thread here , I came up with this. However I am getting an error output: TypeError: ord() expected a character, but string of length 8 found.What am I missing

How to define enum values that are functions?

I have a situation where I need to enforce and give the user the option of one of a number of select functions, to be passed in as an argument to another function: I really want to achieve something like the following: So the following can be executed: Answer Your assumption is wrong. Values can be arbitrary, they are not

Python function that takes one compulsory argument from two choices

I have a function: However, my intention is for the function to take only one argument (either title OR pageid). For example, delete(title=”MyPage”) or delete(pageid=53342) are valid, while delete(title=”MyPage”, pageid=53342), is not. Zero arguments can not be passed. How would I go about doing this? Answer There is no Python syntax that’ll let you define exclusive-or arguments, no. You’d have

Advertisement