Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pag.88===> A última linha do código: return s, não permite a saída em linha por linha como mostra o livro #23

Open
GoogleCodeExporter opened this issue Dec 9, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

o código retorna uma lista ao invés de uma string exibindo o resultado de 
cada laço por linha

                             ERRADO

                        def listaAleatoria(n):
                            s = [0] * n
                            for i in range(n):
                                s[i] = random.random()
                            return s


>>> listaAleatoria(8)
[0.12802238199002747, 0.2645255984028948, 0.9178583669551168, 0.2052996216547002
8, 0.55073244134492516, 0.20682733588527558, 0.64231697113958841, 0.730645729094
09908]
>>>

                                 CERTO
                          def listaAleatoria(n):
                              s = [0] * n
                              for i in range(n):
                                  s[i] = random.random()
                                  print s[i]  

                            >>> listaAleatoria(8)
                            0.15156642489
                            0.498048560109
                            0.810894847068
                            0.360371157682
                            0.275119183077
                            0.328578797631
                            0.759199803101
                            0.800367163582



Original issue reported on code.google.com by [email protected] on 5 Mar 2011 at 10:47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant