Can I do SQL querying in Python?
What packages do I need for that purpose? (specifically for mySQL) Thanks.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
> You are not returning anything.
> You need to use the return keyword otherwise your
> function just generates the data internally then
> throws it away again.
ok, got it - thanks.
my code below did not require a return statement, hence I was assuming
it wouldn't be needed in my function either.
import pandas as pd
cities_lst = pd.read_table("cool_cities.csv")
cities_lst.head()
I was trying to rewrite the above as a function.
Unlike my code above, my function below did not return the first 5
rows, but just nothing:
def cities(file_name):
import pandas as pd
cities_lst = pd.read_t
> A good thing to do but in some cases you have
> to settle for "that's just the way Guido made it" :-)
Thanks for the elaborate answer.
That helps me a lot, as I see some similarities to natural languages:
There is a clearly defined structure, but in some cases purely
arbitrary decisions have be
I am trying to wrap my head around naming conventions & semantics in Python.
Here are two code snippets, and below those two snippets are my questions:
# code snippet 1
file_path = "C:\\Users\\...etl.csv"
with open(file_path) as file_object:
contents = file_object.read()
contents_split = conte
> I wrote this code below
> I was wondering if there is a shorter, more elegant way to accomplish this
> task.
> Thanks!
thank you so much everyone!
List comprehension is really cool. One thing I like about list
comprehension is that you can get a dictionary, tuples or lists as a
result by just c
I wrote this code below which aims to concatenate strings with their
respective string length.
I was wondering if there is a shorter, more elegant way to accomplish this task.
Thanks!
animals = ["Dog", "Tiger", "SuperLion", "Cow", "Panda"]
# step one: convert the animal list into a list of lists
> You forgot the parentheses (), and are returning a reference to the
> function instead of calling it and returning its result. Do this:
> contents = file_object.read()
oh, my bad. Thanks!
> Also, consider using snake_case instead of PascalCase for your
> function name, since the latter
Hi there,
I got this here:
file_path = "C:\\Users\\...\\MyFile.txt" # path shortened for better readability
with open(file_path) as file_object:
contents = file_object.read()
print(contents)
It works.
Now I want to convert the code above into a function.
This is what I wrote:
def FileR
Hi there,
I wrote a function which is supposed to count the number of items on
each index #.
For starters, here's a list I created to test the function:
properties = ["mansion, modern, swimming_pool" , "mansion, historic,
air_conditioning", "penthouse, modern, whirlpool"]
# index 0 = property ty
I wrote a function (shopping list) which calculates the total price of
the purchase (quantity * price) as well as the stock change (stock -
quantity). I know the latter is imperfect (my function does not take
into account if items are out of stock for example, but that's my next
challenge. The func
>> Then, there is another package, along with a dozen other
>> urllib-related packages (such as aiourllib).
>
> Again, where are you finding these? They are not in
> the standard library. Have you been installing other
> packages that may have their own versions maybe?
they are all available via P
Which package should I use to fetch and open an URL?
I am using Python 3.5 and there are presently 4 versions:
urllib2
urllib3
urllib4
urllib5
Common sense is telling me to use the latest version.
Not sure if my common sense is fooling me here though ;-)
Then, there is another package, along wit
Hi there,
I just recently learned how to build a basic web scraper with Python
3.5 (I am learning Python for data analytics purposes). Being new to
coding, I have a question:
How do I know which libraries I need to perform a certain task?
For example, in case of this web scraper (which I built wi
can anyone recommend good resources? I am primarily in search of
simple, clean code examples & practical usecases (Google APIs for
example). Thanks. Right now, I am learning at Codecademy,
Dataquest.io, Datacamp and from "Python Crash Course" by Eric
Matthews.
I am new to programming, Python is my
> PyCharm :)
I dumped VS 2017, after testing several IDEs I am perfectly happy with
PyCharm EDU :) It comes with Python 3.5 and importing & working with
libraries like matplotlib is really, really easy. PyCharm EDU is a
very nice IDE for me as a student
I wanted to start my first project using matplotlib (I have never
worked with libraries before). I am trying to get started with VS
Community 2017, and I am having trouble performing the most basic
tasks such as installing matplotlib. Anyone here using VS 2017? Or,
can anyone recommend an alternati
can anyone point me to good learning resources on this subject?
(python 3)
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
> You need to open the file to create it:
Ok, got you. Thanks, Alan!
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Is there a way to split these two into separate steps:
a) creating a .json file
b) manipulating it (a, r, w ...)
Example:
"import json
number_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
file_name = "my_numbers.json"
with open(file_name, "w") as a:
json.dump(number_list, a)
What if I just wanted to cr
>>> b = "3"+b[2:] #Removing the decimal point so that there are digits only in
>>
>> my_number = 3.14159
>
> Here you assign a floating point number to mmy_number but
> the code Sama wrote was for working with strings read
> from a text file.
>
> You would need to convert it first:
>
> my_number =
Dear Sama,
thank you so much for your explanation and sorry to bother you on the
same subject again.
I learn the most by taking code apart line by line, putting it
together, taking apart again, modifying it slightly ... which is
exactly what I did with your code.
On Tue, Apr 4, 2017 at 3:20 PM, D
Sarma: thank you so much, I checked your code, it works. However, can
you enlighten me what it exactly does?
I do not understand it (yet). Thank you in advance.
file_path = "C:/Users/Rafael/PythonCode/PiDigits.txt"
with open (file_path) as a:
b = a.read()
get_year = input("What year were you
I wrote a program which checks if PI (first one million digits)
contains a person's birth year.
file_path = "C:/Users/Rafael/PythonCode/PiDigits.txt"
with open (file_path) as a:
b = a.read()
get_year = input("What year were you born? ")
for year in b:
if get_year in b:
print("Yo
I can read files like this (relative path):
with open("Testfile_B.txt") as file_object:
contents = file_object.read()
print(contents)
But how do I read files if I want to specify the location (absolute path):
file_path = "C:\Users\Rafael\Testfile.txt"
with open(file_path) as file_object:
>> > I am trying to wrap my head around the super constructor.
Is it possible to embed a super constructor into an if / elif
statement within the child class?
if message == "string A": return X
elif: return Y
How should I modify my code below?
(I couldn't solve that by myself)
class A:
def
I am trying to wrap my head around the super constructor. Simple example:
class A:
def __init__(self):
print("world")
class B(A):
def __init__(self):
print("hello")
super(B, self).__init__()
B()
Then I changed the parent class A like this, as I wanted to test how
Question: When should I use functions?
When should I use classes?
I wrote my program twice: as a function and as a class (I did so for
educational purposes, to better understand both concepts).
Both programs do exactly the same, and the work neatly. Can you advise
when I should use functions and
thanks for your feedback! @boB
I wrote a function that does exactly what I want, and that is:
Create a shopping list and then let the user decide which items (food)
are supposed to be instantly consumed and which ones stored.
def ManageFood():
create_shopping_list = []
prompt = ("Which fo
I am trying to write a food shopping list.
The user should be able to add items to that shopping list, and later
on decide what should happen to those purchased foods: instantly
consumed or stored.
My initial idea was to create a parent class to populate the shopping
list and a child class to mana
LogActivities = []
prompt = ("What have you done today? ")
prompt += ("Enter 'quit' to exit. ")
while True:
activity = input(prompt)
LogActivities.append(activity)
if activity == "quit":
print("Let me recap. This is what you've done today: %s." % ",
" .join(LogActivities))
Th
I want to print individual items from a list like this:
You have a book, towel, shirt, pants in your luggage.
This is my code:
suitcase = ["book", "towel", "shirt", "pants"]
print ("You have a %s in your luggage." % suitcase)
Instead of printing out the items on the list, my code appends the
li
I wrote a program that is supposed to take orders from customers in a bar.
If the desired drink is available, the customer will be served. If
not, he will be informed that the drink is not available. This is what
I wrote:
bar = ["beer", "coke", "wine"]
customer_order = input("What would you like
I want to compare two strings and count the number of identical letters:
stringB = "ABCD"
stringA = "AABBCCDDEE"
for b in stringB:
if b in stringA:
r = 0
r += 1
print (r)
How do I count the output (r) instead of printing it out?
(result should be 4). Thanks!
__
Hey there,
I am trying to wrap my head around Class Inheritance in Python, and I
wrote a little program which is supposed to calculate revenues from
customers who don't get a discount (parent class) and those who get a
30% discount (child class):
class FullPriceCustomer(object):
def __init__(
Hey there,
I am having some issues with splitting strings.
I already know how to split strings that are separated through empty spaces:
def SplitMyStrings():
Colors = "red blue green white black".split()
return (Colors)
print(SplitMyStrings())
>>>
['red', 'blue', 'green', 'white', 'blac
Hej there,
I am very interested to hear your opinion on which version of Python
to use in conjunction with Django. Currently, I am taking a class at
Udemy and they recommend using Python 2.7 with Django 1.6. because
both versions work well with each other.
Over the last few months I got pretty mu
Hej guys,
does anyone know how to activate virtualenv in Windows?
In Terminal it's:
source bin/activate
Couldn't find the corresponding command for Windows that actually worked.
Any ideas?
Thanks!
Rafael
___
Tutor maillist - Tutor@python.org
To uns
>>> Look at this line:
>>>
>>> > if __name__ == " __main__":
>>>
>>
>> do so very closely :)
>
> In monospaced font :)
>
> Took me forever to see it, thanks Gmail...
Ok ... found it ;-)
Thanks!
___
Tutor maillist - Tutor@python.org
To unsubscribe or ch
he test runs through without giving me any output,
and I was wondering what I am doing wrong here?
Raf
On Tue, Dec 17, 2013 at 4:56 PM, Rafael Knuth wrote:
>>> def check_values(a, b):
>>> if all(number >= 0 for number in range(a, b)):
>>> return True
>
>> def check_values(a, b):
>> if all(number >= 0 for number in range(a, b)):
>> return True
>> else:
>> raise ValueError("negative number")
>>
>> And:
>> def PositiveCalculator(a, b):
>> if a > 0 and b > 0:
>> return a + b
>> else:
>> raise Va
> BUT: this really doesn't make much sense! Your if construct is a lot more
> readable than what any or all would give you in this example.
> As pointed out repeatedly here, you can always replace any() and all() with
> a combination of for and if, it's really a question of readability (and
> style
got it!
Thanks, Peter
On Tue, Dec 17, 2013 at 4:27 PM, Peter Otten <__pete...@web.de> wrote:
> Rafael Knuth wrote:
>
>> Hej there,
>>
>>> I use any() and all() frequently. For example, suppose you have a
>>> function that takes a list of numbers, an
Hej there,
> I use any() and all() frequently. For example, suppose you have a
> function that takes a list of numbers, and they are all supposed to be
> positive.
>
> def calculate_values(numbers):
> if all(number > 0 for number in numbers):
> # do the calculation
> else:
>
Hey there,
I am currently looking into all built in functions in Python 3.3.0,
one by one, in order to understand what each of them specifically does
(I am familiar with some of them already, but most built in functions
are still alien to me). I am working with the Python documentation
http://docs
Hej there,
>> number = 9
>> for element in range(2,9):
>> 3 % 2 != 0:
>> My assumption is that the program should end the loop after the first
>> iteration again and it then should return True.
>
> No. If it did that, it wouldn't be a *loop* at all, would it? The whole
> reason loops (for and whil
Hej,
I stumbled upon this program here (Python 3.3.0) and I don't quite
understand how the for loop plays with the return True statement:
def is_prime(number):
for element in range(2, number):
if number % element == 0:
return False
return True
Now, I would expect the
Hej Steven,
thanks for the clarification.
I have two questions - one about map function and the other about return.
> So, in mathematics we might have a mapping between (let's say) counting
> numbers 1, 2, 3, 4, ... and the even numbers larger than fifty, 52, 54,
> 56, ... and so on. The mapping
Hej there,
> I don't know if everyone would consider this more elegant but it's
> certainly shorter:
Thanks!
def DigitSum(YourNumber):
> ... return sum(map(int, YourNumber))
> ...
DigitSum('55')
> 10
I don't understand yet what the "map" function does - can you explain?
I read the
>> Tu sum it up (aha!): you algorithm is the right and only one
>
> No, it's not the only one. It's certainly the most obvious one, but there is
> also the pure numbers approach pointed out by me and Alan.
So far I received 7 different alternative suggestions, both pure
numbers & mixed int/str app
Thanks, guys - got it! I was suspecting that my solution is too
complex and that there must be a simpler way to convert integers into
a digit sum. Have a great morning/day/evening, Raf
On Mon, Dec 9, 2013 at 9:23 AM, Amit Saha wrote:
> On Mon, Dec 9, 2013 at 6:08 PM, Rafael Knuth wrote:
>
Hej there,
I wrote a program that converts an integer into a digit sum:
def DigitSum(YourNumber):
DigitList = []
YourNumber = str(YourNumber)
for i in YourNumber:
DigitList.append(int(i))
print(sum(DigitList))
DigitSum(55)
>>>
10
It actually works but I was wondering if
Hey there,
I struggle to understand what unit testing specifically means in
practice and how to actually write unit tests for my code (my gut is
telling me that it's a fairly important concept to understand).
Over the last few days I learned how to write and work with classes, I
learned quite a l
> We've already established that you've an "off by one" error in the year, but
> let's do a closer analysis of your code and mine.
Ok, got it - thank you for the clarification Mark.
No more questions for today, I learned a lot - thank you all!
:-)
All the best,
Raf
> for x, country in zip ( range (2009,2014), PopularCountries):
> print (x, country)
>
> And yes, Rafael, you can zip together any number of iterators this way.
>
> --
> DaveA
Thanks Dave. Got it!
Raf
___
Tutor maillist - Tutor@python.org
To unsu
Hej there,
> That's very poor coding, if you're given a function that does exactly what
> you want, why rewrite it and worse still, get it wrong?
I don't quite understand. I took that advice, tried it - it worked,
and then I figured out there's also another way to get there.
The output from the "
Hej there,
> Loop around your list using the enumerate builtin function and an
> appropriate value for start, see
> http://docs.python.org/3/library/functions.html#enumerate
thanks! That hint was very helpful, and I rewrote the program as
follows (I learned how to enumerate just yesterday and I f
Hej there,
I am writing a little throw away program in order to better understand
how I can loop through a variable and a list at the same time. Here's
what the program does and how it looks like: It counts the number of
backpackers (assuming a growth rate of 15 % year on year) over the
last five
> Do you understand how that works?
Yep. It's crystal clear now. Thank you.
It took a while till I got it, though ;-)
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Hej there,
I am trying to figure out how exactly variables in nested loops are
generated, and don't get it 100% right yet. Here's my code:
for n in range(2, 10):
for x in range(2, n):
if n % x == 0:
print(n, 'equals', x, '*', n//x)
break
else:
print
> Does German have anything similar? (I presume you are German.)
Ich nehme mir die Freiheit. (present)
Ich habe mir die Freiheit genommen. (past)
And in Polish:
Pozwalam sobie. (present)
Pozwoliłem sobie. (past)
;-)
Cheers,
Raf
___
Tutor maillist
Thank you, Peter!
On Wed, Nov 27, 2013 at 9:45 AM, Peter Otten <__pete...@web.de> wrote:
> Rafael Knuth wrote:
>
>> simple issue I couldn't find a solution for:
>>
>> YourName = input(str("What is your name?"))
>> print("Hello", YourN
> OK, That's what you'd expect in 3.3 because raw_input is now input().
>
> But in that case input() should not do anything with your input.
>
> Can you post a session showing the input and the odd behaviour?
YourName = input(str("What is your name ?"))
print("Hello", YourName)
Exemplary input &
Hej there,
simple issue I couldn't find a solution for:
YourName = input(str("What is your name?"))
print("Hello", YourName)
When executing the program, in case the user input is "for", "not",
"True", "while" Python interprets that as a command and changes the
input's color to the corresponding
stead of asking: "What's wrong with this code?" I should ask myself:
"What's wrong with my assumption about this code?" whenever I hit the
wall.
Again, thank you so much & have a great week!
Raf
On Sun, Nov 24, 2013 at 4:48 PM, Alan Gauld wrote:
> On 24/11/
Hej there,
I stumbled upon the "continue" statement and to me it looks like it
does exactly the same as else. I tested both else and continue in a
little program and I don't see any differences between both. Is my
assumption correct or wrong? If the latter is the case: Can you give
me examples of
a, b = b, b + a
print(a) # a = b = 17
print(b) # b + a = 17 + 11 = 28
# 6th run
a, b = b, b + a
print(a) # a = b = 28
print(b) # b + a = 28 + 17 0 45
All the best,
Raf
On Sun, Nov 24, 2013 at 12:33 PM, Dave Angel wrote:
> On Sun, 24 Nov 2013 11:24:43 +0100, Rafael Knuth
> wrote:
>
Hej there,
I am making a couple wrong assumptions about the program below, but I
do not know where my thinking mistake is. I have some trouble
understanding what exactly happens within this loop here:
a, b = 0, 1
while b < 10:
print(b)
a, b = b, a +b
What I would expect as an outcome of
> So, what to do about it? While the Python interactive interpreter is
> mighty powerful, it does have some limitations, and this is one of them.
> You just have to get used to the fact that it is not well-suited for
> editing large blocks of code. It is excellent for trying out small
> snippets, o
> See? It has no output. By the way, the python REPL is your friend! Use it
> often when you can't figure out what is happening.
Oh, I didn't even know that such a thing exists :-) Cool!
Unfortunately, I only found Python REPLs for version 2.7.2 or lower.
Is there a REPL for 3.3.0 ..?
Thanks,
R
@Peter
@Steven
@Don
@Danny
thank you *so much" for explaining the concept of a nested for loop!
Your simplified example Steven made it very clear to me:
for x in range(2, 7):
print("outer loop, x =", x)
for y in range(2, x):
print("inner loop, x =", x, "y =", y)
I have only one q
> Oh, wait, I see you are using Python 3.0. Don't. Python 3.0 is not
> supported because it is buggy. You should use 3.1, or better still, 3.3.
> Python 3.3 is much better than 3.1 or 3.2, and 3.0 is buggy and slow.
What I was trying to say is that sometimes I get runtime errors even
if nothing's
Hej there,
I noticed that sometimes when I do lots of modifications within a
program, I get runtime errors even if the program is "clean". I
realized that first time when I copy and pasted a program into a new
window - it miraculously ran without any problems. Although it was
exactly the same prog
Hej there,
newbie question: I struggle to understand what exactly those two
subsequent for loops in the program below do (Python 3.3.0):
for x in range(2, 10):
for y in range(2, x):
if x % y == 0:
print(x, "equals", y, "*", x//y)
break
else:
print(x
>> I'm only stuck at one point: How do I loop back to the beginning in
>> case the user input is invalid?
>
>
> Look at Peter's example. He set a variable to false when the input was
> wrong. You can check that value in your while loop.
Ok, got you!
print("TIME TRACKING")
while True:
hours_w
Hej there,
@David @Peter @Amit:
Thank you so much - you guys helped me understand my misconceptions
and I learned a couple new things.
On Thu, Nov 21, 2013 at 12:44 PM, Amit Saha wrote:
> On Thu, Nov 21, 2013 at 9:00 PM, Rafael Knuth wrote:
>> Hej there,
>>
>> I want to
Hej there,
I want to use a while loop in a program (version used: Python 3.3.0),
and I expect it to loop unless the user enters an integer or a
floating-point number instead of a string.
print("TIME TRACKING")
hours_worked = input("How many hours did you work today? ")
while hours_worked != str()
Hello Jay,
thanks for your reply.
On Thu, Oct 24, 2013 at 11:45 PM, Jay Lozier wrote:
> On Thu, 2013-10-24 at 21:57 +0200, Rafael Knuth wrote:
> > Hej,
> > I can't get Python 3.3 up and running (it's properly installed but I
> > can't launch it), and I wa
Hej,
I can't get Python 3.3 up and running (it's properly installed but I can't
launch it), and I was wondering if anyone using OpenSUSE 12.3 had similar
issues. SUSE community folks weren't really able to help me, so I was
wondering I give it a try here.
Thanks,
Rafael
Dominik,
> OTOH, *if* your claim that you understand the concepts mentioned by Dave
> isn't an ill-minded overestimation, I wonder why you don't go and use
> these skills. Doyou lack a concept of how to logically build up your
> code, or what's the main issue?
Exactly. I didn't know how to put th
Hej Dave,
thank you for your response.
> Your original program had some code that interacted with the user. So
> when you went from that to a giant print statement, I, and proably many
> others, thought you were just kidding.
I noticed that, but I was serious about that. I mean, my giant print
:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA512
>
>
>
> Rafael Knuth schrieb:
>>Dominik,
>>
>>> it's not your program - it's your attitude. We expect you to learn
>>for yourself as well, and putting the commands you output into a script
>&g
Dominik,
> it's not your program - it's your attitude. We expect you to learn for
> yourself as well, and putting the commands you output into a script and
> execute it clearly isn't beyond what we can expect from someone who can use a
> mail program.
Thanks for the clarification, you were the
lly
able to a list, to write to and reads from it (in a very primitive
manner though). Can anyone explain? However, I find that hint to
learn to use SQLite - thank you for that.
All the best,
Rafael
Rafael
On Mon, Sep 30, 2013 at 1:43 AM, Alan Gauld wrote:
> On 29/09/13 21:42, Rafael
Joel,
I am terribly sorry, I erased that thread accidentally without having
read it, and I now found it.
Thank you and again - and apologies!
Rafael
On Mon, Sep 30, 2013 at 12:35 PM, Joel Goldstick
wrote:
> You restarted the same thread from yesterday where you got several replies.
> Go and find
Hej there,
apologies if you're receiving my mail for a second time, I had some
issues with Google and I just want to make sure you will receive my
email.
I am writing a to do list program in Python 3.0.
Last week, I shared my first iteration on the mailing list, and the
feedback was that I shoul
Hej there,
I am writing a to do list program in Python 3.0.
Earlier this week, I shared my first iteration on the mailing list,
and the feedback was that I should learn how to create, write to and
read from a text file – which I did. Below please find my second
iteration. I know my program is sup
Dave,
thank you so much, I will proceed as you suggested.
Currently, I am not 100% sure I get it right, but I will start iterating
now.
All the best,
Rafael
> > Can you advise how I should proceed in order to
> > improve my To Do List program based on the code I wrote so far
> > (insofar i
Alan,
On Wed, Sep 25, 2013 at 9:11 PM, Alan Gauld wrote:
> On 25/09/13 18:42, Rafael Knuth wrote:
>
>> I want to write a simple program (To Do List) that stores the input
>> data (action items on To Do List). Currently I can only input items
>> but the program I
Hej there,
I want to write a simple program (To Do List) that stores the input
data (action items on To Do List). Currently I can only input items
but the program I wrote doesn't store them.
Can you help?
Thanks,
Rafael
Here's the code I wrote so far:
print("This is my to do list")
Monday =
Gents,
thank you all for your help. One of you guys asked me to try out your
suggestions and then tell you how it goes. Here we go! First, let me
recap briefly what the expected outcome of my program was and which
difficulties I encountered at the beginning. I was writing a program
in Python 3.3.0
to flip a coin 10 x times and then count the number of
heads and tails.
That's very much it.
On Fri, May 24, 2013 at 1:08 PM, Asokan Pichai wrote:
>
>
> On Fri, May 24, 2013 at 4:31 PM, Rafael Knuth wrote:
>
>> Hello,
>>
>> I am writing a program in Python 3.3.
Hello,
I am writing a program in Python 3.3.0 which flips a coin 10 x times and
then counts the number of heads and tails. It obviously does something else
than I intended, and I am wondering what I did wrong:
import random
print ("""
This program flips a coin 10 times.
It then counts the numb
wrote:
>
> On Mon, May 20, 2013 at 11:31 AM, Rafael Knuth
wrote:
> >
> > Hello,
> >
> > I wrote a simple program, and I was expecting that I would get 100
different random numbers. Instead, I am getting 100 times exactly the same
random number. Can anyone advise
" + str(age) + " year old human being
born in " + birthplace + " you probably like sushi.")
elif meal == 3:
print("Well, " + name + " as a " + str(age) + " year old human being
born in " + birthplace + " you probably like pizza.&qu
Hello,
I wrote a simple program, and I was expecting that I would get 100
different random numbers. Instead, I am getting 100 times exactly the same
random number. Can anyone advise how I should alter my program?
Thank you!
All the best,
Rafael
PS. I am using Python 3.3.0
print ("""
This game
x27;s your name?"))
Can you clarify? Thank you in advance.
On Sun, May 19, 2013 at 3:16 PM, Oscar Benjamin
wrote:
> On 19 May 2013 14:04, Rafael Knuth wrote:
> > Hello,
>
> Hello, please post in plain text (not html) in future. Also you should
> mention what version of Pytho
Hello,
here's a tiny little program I wrote:
import random
print("""
This is a magic super computer.
He will ask you a couple of questions.
An ultra-complicated algorithm will then figure out what your favorite meal
is.
""")
name = str(input("What is your name? "))
age = int(input("How old
Thank you - that makes perfectly sense.
Also, I am new to the list, and I appreciate your suggestion.
I will include error tracebacks in the future.
All the best,
Rafael
On Thu, May 16, 2013 at 9:14 PM, Dave Angel wrote:
> On 05/16/2013 02:58 PM, Rafael Knuth wrote:
>
>> Hej,
>
Hej,
I wrote a tiny little program which I was hoping would take a number as
input, square and print it:
square = input ("Enter a number. ")
print (str(square) + " squared is " + str(square ** 2))
It seems I can't work with variables within the str() string method, and I
was wondering if anyone
100 matches
Mail list logo