Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Get the biggest number from a two dimensional list
Post: RE: Get the biggest number from a two dimensional ...
|
rs74 |
Homework |
13 |
3,942 |
Aug-09-2020, 02:48 PM |
|
|
Thread: Get the biggest number from a two dimensional list
Post: RE: Get the biggest number from a two dimensional ...
(Aug-09-2020, 11:30 AM)Yoriz Wrote: found_max = max(something) returns the maximum, you have to do something with the returned value
pseudo code
[python]
create an empty list max_inner_list
Val... |
|
rs74 |
Homework |
13 |
3,942 |
Aug-09-2020, 01:36 PM |
|
|
Thread: Get the biggest number from a two dimensional list
Post: RE: Get the biggest number from a two dimensional ...
Now I get one number but it is not the biggest. Because online course/tutorial, no teacher to ask support.
li = []
for m in l:
max(l)
return m |
|
rs74 |
Homework |
13 |
3,942 |
Aug-09-2020, 11:09 AM |
|
|
Thread: Get the biggest number from a two dimensional list
Post: RE: Get the biggest number from a two dimensional ...
This is what I get (same result both rows, biggest should only show the largest number):
list: [[3543, 983], [2782, 1863], [4784, 2178], [3676, 2152], [3643, 5325], [4830, 362], [5752, 3868], [1551, ... |
|
rs74 |
Homework |
13 |
3,942 |
Aug-09-2020, 06:48 AM |
|
|
Thread: Get the biggest number from a two dimensional list
Post: RE: Get the biggest number from a two dimensional ...
Thanks. But how to write it inside the function instead? Should I use brackets there? |
|
rs74 |
Homework |
13 |
3,942 |
Aug-08-2020, 11:59 AM |
|
|
Thread: Get the biggest number from a two dimensional list
Post: Get the biggest number from a two dimensional list
Small extra assignment, to get the biggest number from a two-dimensional list. Now getting all the data from list in brackets, needs only the biggest.
import random
def biggest(list):
maxvalue =
... |
|
rs74 |
Homework |
13 |
3,942 |
Aug-07-2020, 04:00 PM |
|
|
Thread: Print part of a variable
Post: RE: Print part of a variable
|
rs74 |
General Coding Help |
4 |
2,524 |
Jul-27-2020, 04:39 PM |
|
|
Thread: Print part of a variable
Post: RE: Print part of a variable
Variable lenght is passed on to a function where meters is needed, in the function I will print variable lenght but without meters. |
|
rs74 |
General Coding Help |
4 |
2,524 |
Jul-27-2020, 03:59 PM |
|
|
Thread: Print part of a variable
Post: Print part of a variable
Hm, I want to print only 27 + a random generated number so it should be (for example) 2717. The content of variable meters should not be included, not sure how to do it.
lenght = meters + ", 27" + st... |
|
rs74 |
General Coding Help |
4 |
2,524 |
Jul-27-2020, 03:50 PM |
|
|
Thread: Binary to decimal, print the decimal
Post: RE: Binary to decimal, print the decimal
(Jul-11-2020, 09:41 AM)DPaul Wrote: You might take a look a 2 things:
1) your def outputConverted receives 1 argument, with a name that is not used.
2) the indentation of line 20
Paul
Thanks, the i... |
|
rs74 |
Homework |
3 |
1,991 |
Jul-12-2020, 11:28 AM |
|
|
Thread: Binary to decimal, print the decimal
Post: Binary to decimal, print the decimal
Trying to print the decimal number after each row, no success. Is it correct to use a variable (decimal) and then print it?
import random
def outputConverted(binary):
decimal = int(bin,2)
print(... |
|
rs74 |
Homework |
3 |
1,991 |
Jul-11-2020, 08:04 AM |
|
|
Thread: Not getting the return value
Post: RE: Not getting the return value
(Jul-04-2020, 07:39 AM)ndc85430 Wrote: You aren't printing the return value on line 33, so it's just thrown away. Did you mean to include the call to your function on line 31?
Yes, but how to includ... |
|
rs74 |
General Coding Help |
4 |
2,219 |
Jul-04-2020, 07:44 AM |
|
|
Thread: Not getting the return value
Post: Not getting the return value
Having some issues with return. Would like to get the return value (middle number) printed after "Middle number is ". Something obvious I presume but I just can't see it. :(
#still learning the basic... |
|
rs74 |
General Coding Help |
4 |
2,219 |
Jul-04-2020, 07:39 AM |
|
|
Thread: Repeat question (for loop)
Post: RE: Repeat question (for loop)
Thanks for your feedback (and patience). Surely, will read more about range and specially indent.
import random
from random import randrange
for i in range(1, 6):
x = random.randrange(0, 10... |
|
rs74 |
Homework |
7 |
6,349 |
Jun-17-2020, 03:17 PM |
|
|
Thread: Repeat question (for loop)
Post: RE: Repeat question (for loop)
Updated code, still no success. User is beeing asked only once. So I am thinking of the for loop which contains the variable i. Why? Well, good question. I am just learning by doing so would like to h... |
|
rs74 |
Homework |
7 |
6,349 |
Jun-17-2020, 02:41 PM |
|
|
Thread: Repeat question (for loop)
Post: RE: Repeat question (for loop)
(Jun-17-2020, 12:44 PM)buran Wrote: sum is built-in function and you should not use it as variable name
...is it that you want to ask 5 different questions
Oh, will never use sum as a variable a... |
|
rs74 |
Homework |
7 |
6,349 |
Jun-17-2020, 12:53 PM |
|
|
Thread: Repeat question (for loop)
Post: Repeat question (for loop)
Trying to make a small program where a user can answer basic questions (1+1 etc). But the questions should be random, in my code, no random numbers are generated. Is the for loop in wrong place?
impo... |
|
rs74 |
Homework |
7 |
6,349 |
Jun-17-2020, 12:16 PM |
|
|
Thread: Sort methods
Post: RE: Sort methods
(Jun-12-2020, 08:16 AM)buran Wrote: Read evaluation order and operator precedence
Quote:Python evaluates expressions from left to right. Notice that while evaluating an assignment, the right-hand s... |
|
rs74 |
General Coding Help |
5 |
2,335 |
Jun-12-2020, 08:20 AM |
|
|
Thread: Sort methods
Post: RE: Sort methods
Which function is the first to run? These functions should just be sorted (by me in general, not the program) in a list in the way they are executed(?).
Example:
multi
mod
sub
div
add |
|
rs74 |
General Coding Help |
5 |
2,335 |
Jun-12-2020, 07:50 AM |
|
|
Thread: Sort methods
Post: Sort methods
a = add(multi(3));
a = a + mod(div(a + 3)) + sub(12)
How (and why) should this functions (add, multi, mod, div, sub) be sorted? I am thinking like this ->
1. multi (a = a) (first function)
2. ... |
|
rs74 |
General Coding Help |
5 |
2,335 |
Jun-12-2020, 07:26 AM |