top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What range(5) returns in python 3.4? will it return entire list or single object for each iteration?

+1 vote
462 views
What range(5) returns in python 3.4? will it return entire list or single object for each iteration?
posted Jan 11, 2015 by Gnanendra Reddy

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

It returns one object in each iteration see the following simple example -

for i in range(5):
     print(i)

Output

0
1
2
3
4

See the other usage of range -

range(5, 10)
   5 through 9

range(0, 10, 3)
   0, 3, 6, 9

range(-10, -100, -30)
  -10, -40, -70
answer Jan 11, 2015 by Salil Agrawal
in 3.4 version it is not showing 5 through 9 when i execute range(5,10) instead of it is showing the same i.e range(5,10) plz clarify this
Should not be its a basic function and should be consistent across the versions. Check your code for possible issues (may be see the following code for reference)
http://codepad.org/RDJpsCl7
Similar Questions
+1 vote

I want to install path.py in my Python 3.4 environment on a Centos 5 box. My /usr/local/bin/ contains:

easy_install-3.4 
python3.4  
etc. 

We are behind a proxy server and I tried this:

# /usr/local/bin/easy_install-3.4 path.py 

Searching for path.py 
Reading https://pypi.python.org/simple/path.py/ 
Download error on https://pypi.python.org/simple/path.py/: hostname '172.29.68.1  
' doesn't match either of 'www.python.org', 'python.org', 'pypi.python.org',  
'docs.python.org', 'testpypi.python.org', 'bugs.python.org', 'wiki.python.org',  
'hg.python.org', 'mail.python.org', 'packaging.python.org', 'pythonhosted.org',  
'www.pythonhosted.org', 'test.pythonhosted.org', 'us.pycon.org', 'id.python.org' --  
Some packages may not be found! 

Couldn't find index page for 'path.py' (maybe misspelled?), Am I best to use pip or easy_install? also if easy_install, how can I fix the above error?

+1 vote

I understand there have been changes to the way that extensions are supposed to be built for windows. Is there any user documentation regarding these changes?

Last time I looked the appropriate Visual Studio hadn't been release so I guess I will need to use my MSDN skills (or incantations) to first get that installed.

+1 vote

For example:

a=[-15,-30,-10,1,3,5]

I want to find a negative and a positive minimum.

example: negative
print(min(a)) = -30

positive
print(min(a)) = 1
...