Upvote Upvoted 0 Downvote Downvoted
python help
posted in Off Topic
1
#1
0 Frags +

please help me i need to combine these two lists which i already did ( the [[11, 13,15], [26, 30]] )

http://puu.sh/CY68v/4d4db2d16d.png

but now im stuck because i dont know how to follow these steps

https://puu.sh/CY4av/7329111f61.jpg

to print everything in the list on a single line to get the output of this

http://puu.sh/CY6hk/3f57aa4b1e.png

pls help

please help me i need to combine these two lists which i already did ( the [[11, 13,15], [26, 30]] )
[img]http://puu.sh/CY68v/4d4db2d16d.png[/img]

but now im stuck because i dont know how to follow these steps
[img]https://puu.sh/CY4av/7329111f61.jpg[/img]

to print everything in the list on a single line to get the output of this
[img]http://puu.sh/CY6hk/3f57aa4b1e.png[/img]

pls help
2
#2
5 Frags +

for sublist in EList:
for number in sublist:
print(number, end=" ")

for sublist in EList:
for number in sublist:
print(number, end=" ")
3
#3
0 Frags +
jennydeathfor sublist in EList:
for number in sublist:
print(number)

it need to all be on the same line
i tried what you have and i got this

http://puu.sh/CY6Cf/e1f3163e55.png

EDIT: THANK

[quote=jennydeath]for sublist in EList:
for number in sublist:
print(number)[/quote]
it need to all be on the same line
i tried what you have and i got this
[img]http://puu.sh/CY6Cf/e1f3163e55.png[/img]

EDIT: THANK
4
#4
6 Frags +

There's an example of a nested for loop in the Python docs.
https://wiki.python.org/moin/ForLoop

(also are you in the middle of an exam right now, cause the file name is exam1.py lol)

There's an example of a nested for loop in the Python docs.
https://wiki.python.org/moin/ForLoop

(also are you in the middle of an exam right now, cause the file name is exam1.py lol)
5
#5
1 Frags +

yeah i forgot about printing on one line, i edited my post so it does that :) it might be useful to know that the end=" " in print() tells python that instead of printing a newline after each number it has to print a space instead, which is why it prints it all on one line.

yeah i forgot about printing on one line, i edited my post so it does that :) it might be useful to know that the end=" " in print() tells python that instead of printing a newline after each number it has to print a space instead, which is why it prints it all on one line.
6
#6
-1 Frags +

https://puu.sh/Df79D/eb6800aaaf.jpg

http://puu.sh/Df7kI/32360638bb.png

wanted to study this for later, anyone know how to solve this
punctuation doesent matter, just wanted to learn how to do the specific functions

[img]https://puu.sh/Df79D/eb6800aaaf.jpg[/img]
[img]http://puu.sh/Df7kI/32360638bb.png[/img]
wanted to study this for later, anyone know how to solve this
punctuation doesent matter, just wanted to learn how to do the specific functions
7
#7
0 Frags +

Are they letting you import packages for this? I'd use pandas to make the table if so.

In your function, I'd define an empty list for the times in seconds and an empty list for the times in minutes. For each time in your list, multiply it by 60 to get the number of seconds and apply your formula to get the meters. Use string formatting to add the 'sec' and 'meters' to each of these and append it to your empty list.

If you use pandas you can construct the table (using pd.DataFrame( ) ) as a dictionary where the keys are the column headings ('Time' and 'Distance Fallen') and the values are the lists you just made. You can then just make the function return your table.

Are they letting you import packages for this? I'd use pandas to make the table if so.

In your function, I'd define an empty list for the times in seconds and an empty list for the times in minutes. For each time in your list, multiply it by 60 to get the number of seconds and apply your formula to get the meters. Use string formatting to add the 'sec' and 'meters' to each of these and append it to your empty list.

If you use pandas you can construct the table (using pd.DataFrame( ) ) as a dictionary where the keys are the column headings ('Time' and 'Distance Fallen') and the values are the lists you just made. You can then just make the function return your table.
8
#8
1 Frags +

I feel like that's a relatively convoluted way to go about something you can accomplish in a for loop.

for each item in list
    time -> item * 60
    distance -> 1/2 * g * time^2
    print "distance: " + distance + "time: " + time

or something like that

I feel like that's a relatively convoluted way to go about something you can accomplish in a for loop.

[code]
for each item in list
time -> item * 60
distance -> 1/2 * g * time^2
print "distance: " + distance + "time: " + time
[/code]

or something like that
9
#9
0 Frags +

Zesty, pandas is overkill for that

Indecency, https://pastebin.com/hnJ8GbER

Zesty, pandas is overkill for that

Indecency, https://pastebin.com/hnJ8GbER
10
#10
0 Frags +

^ That could work too, It would just bother me because the table wouldn't be properly aligned.

^ That could work too, It would just bother me because the table wouldn't be properly aligned.
11
#11
3 Frags +
skappa

probably shouldn't do literally his entire assignment for him, imo...

[quote=skappa][/quote]

probably shouldn't do literally his entire assignment for him, imo...
12
#12
1 Frags +
import calculus

am i right haha

[code]import calculus[/code] am i right haha
13
#13
0 Frags +
Jenkinsskappa
probably shouldn't do literally his entire assignment for him, imo...

it doesent matter, im studying this for a test later and this assignment has been past, just trying to learn it

ZestyAre they letting you import packages for this? I'd use pandas to make the table if so.

In your function, I'd define an empty list for the times in seconds and an empty list for the times in minutes. For each time in your list, multiply it by 60 to get the number of seconds and apply your formula to get the meters. Use string formatting to add the 'sec' and 'meters' to each of these and append it to your empty list.

If you use pandas you can construct the table (using pd.DataFrame( ) ) as a dictionary where the keys are the column headings ('Time' and 'Distance Fallen') and the values are the lists you just made. You can then just make the function return your table.

and no, my professor just stated that we should really only use two functions that print out the entire assignment for us, one for the top task1A and another for the task2A thats seperated by the dashed line but thanks
edit: also thank u

[quote=Jenkins][quote=skappa][/quote]

probably shouldn't do literally his entire assignment for him, imo...[/quote]

it doesent matter, im studying this for a test later and this assignment has been past, just trying to learn it
[quote=Zesty]Are they letting you import packages for this? I'd use pandas to make the table if so.

In your function, I'd define an empty list for the times in seconds and an empty list for the times in minutes. For each time in your list, multiply it by 60 to get the number of seconds and apply your formula to get the meters. Use string formatting to add the 'sec' and 'meters' to each of these and append it to your empty list.

If you use pandas you can construct the table (using pd.DataFrame( ) ) as a dictionary where the keys are the column headings ('Time' and 'Distance Fallen') and the values are the lists you just made. You can then just make the function return your table.[/quote]

and no, my professor just stated that we should really only use two functions that print out the entire assignment for us, one for the top task1A and another for the task2A thats seperated by the dashed line but thanks
edit: also thank u
14
#14
8 Frags +
twiikuu
import calculus
am i right haha
from school import homework
print homework.do() 

i freakin love python!!!!!

[quote=twiikuu][code]import calculus[/code] am i right haha[/quote]
[code]from school import homework
print homework.do() [/code]

i freakin love python!!!!!
15
#15
7 Frags +

how long do you think it woudl take tasheem to install pandas?

how long do you think it woudl take tasheem to install pandas?
Please sign in through STEAM to post a comment.