Jump to content

I've been given 4 python homework tasks to complete over the holidays, they all seem extremely hard for someone of my skill level. We learned basic python in class about 6 months ago and even if I was given these tasks then it would be hard for me. The most I can remember is while loops, variables, if statements, for loops (sort of) and obviously outputting text.

 

I need a bit of help with the tasks

 

1. Make a program that asks the user for a series of numbers until they either want to output the average or quit the program. Extension: Expand the program to print the median and mode averages too, include options so that if the user wants to, they can save their list of numbers to a text file and read them back out later on. Solve it using a flowchart, pseudo code and programme code (python or php/html)

 

2. Make a program to check whether an email address is valid or not. For instance, you could make sure there are no spaces, that there is an @ symbol and a dot somewhere after it. Also check the length of the parts at the start, and that the end parts of the address are not blank. Extension: When an email address is found to be invalid, tell the user exactly what they did wrong with their email address rather than just saying it's invalid. Allow the user to choose to give a text file with a list of addresses and have it process them all automatically. Solve it using a flowchart, pseudo code and programme code (python or php/html)

 

3. Pig Latin is a game of alterations played on the English language. To create the pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an "ay" is affixed (E.g "banana" would yield "anana-bay"). Solve it using a flowchart, pseudo code and programme code (python or php/html)

 

4. Create a program that will keep track of items for a shopping list. The program should allow you to keep adding new items. You should be able to record which shop you're going to visit for them. Extension: Extend the program to record what priority the item is. Extend the program to record whether or not you have purchased the item yet. Extend the program to say how much you are willing to pay for each item. Extend the program to say the quantity needed for each item. Make part of your program that can give you the approximate total of what you intend to spend on your shopping trip. Make sure you take into account whether you have already bought the item or not. Solve it using a flowchart, pseudo code and programme code (python or php/html)

 

My fingers hurt from typing all of that, ouch

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/
Share on other sites

Link to post
Share on other sites

What sort of help do you need? You're not expecting us to write it for you right?

 

The first one seems easy enough, if you know the bare minimum about programming it should be a piece of cake. So is the second one if you know how to work with strings.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-5680043
Share on other sites

Link to post
Share on other sites

What sort of help do you need? You're not expecting us to write it for you right?

 

The first one seems easy enough, if you know the bare minimum about programming it should be a piece of cake. So is the second one if you know how to work with strings.

 I just need help explaining how to go about it

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-5680112
Share on other sites

Link to post
Share on other sites

 I just need help explaining how to go about it

 

1) Asking the user for numbers should not be a problem. I suggest you save them as strings in a list and conver them later, so you can get a "quit" or "show average" command. To work out the average simply convert the list to numbers, sum them and divide them by the number of numbers; basic math. For the extension just add the median and mode formulas. As for saving to a text fine, read up on I/O functions in python, it's not hard.

 

2) Ask for the address, then scroll through it with a loop. Return error if the loop finds an invalid character, and if it finds an @ make it change a boolean variable that tells you if there is an @ or not. If you find another one and the boolean is set to "true", return error. Then you can use if commands to return different errors. For the file, again, read up on I/O, it's pretty straight forward.

 

3) I don't see the problem here, the logic is extremely simple and explained thoroughly in the question. Take the first letter, place it in front and add "ay". This isn't c, the strings are dynamic.

 

4) this is done with multi-dimensional lists. Make a list of items, where each item is a second list composed of the name of the product, the price, the shop, the priority etc. You may want to use a separate list to record which items you have purchased already and another for the price you're willing to pay.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-5680568
Share on other sites

Link to post
Share on other sites

1) Asking the user for numbers should not be a problem. I suggest you save them as strings in a list and conver them later, so you can get a "quit" or "show average" command. To work out the average simply convert the list to numbers, sum them and divide them by the number of numbers; basic math. For the extension just add the median and mode formulas. As for saving to a text fine, read up on I/O functions in python, it's not hard.

 

2) Ask for the address, then scroll through it with a loop. Return error if the loop finds an invalid character, and if it finds an @ make it change a boolean variable that tells you if there is an @ or not. If you find another one and the boolean is set to "true", return error. Then you can use if commands to return different errors. For the file, again, read up on I/O, it's pretty straight forward.

 

3) I don't see the problem here, the logic is extremely simple and explained thoroughly in the question. Take the first letter, place it in front and add "ay". This isn't c, the strings are dynamic.

 

4) this is done with multi-dimensional lists. Make a list of items, where each item is a second list composed of the name of the product, the price, the shop, the priority etc. You may want to use a separate list to record which items you have purchased already and another for the price you're willing to pay.

For Pig Latin translation, be aware that you only move the first letter to back of the word if the first letter is a consonant (not a, e, i, o, or u) Example: part -> artpay

If the word does start with a vowel, just add "ay" to the end. Example: aardvark -> aardvarkay

 

If you're having trouble remembering how to code in Python then look over any scripts that you created while you were learning Python. You can also go partway through the codecademy course, it's a great refresher.

CPU: AMD FX-6300 4GHz @ 1.3 volts | CPU Cooler: Cooler Master Hyper 212 EVO | RAM: 8GB DDR3

Motherboard: Gigabyte 970A-DS3P | GPU: EVGA GTX 960 SSC | SSD: 250GB Samsung 850 EVO

HDD: 1TB WD Caviar Green | Case: Fractal Design Core 2500 | OS: Windows 10 Home

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-5682948
Share on other sites

Link to post
Share on other sites

  • 1 year later...

I was wondering if you ever finished the tasks you were given because i have the same problem and do not know how to do them. I was wondering if you could help me out a bit because I dont know that much went to comes to computer science... kinda failing even though I pay attention.

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-8308607
Share on other sites

Link to post
Share on other sites

3 hours ago, Dessire said:

I was wondering if you ever finished the tasks you were given because i have the same problem and do not know how to do them. I was wondering if you could help me out a bit because I dont know that much went to comes to computer science... kinda failing even though I pay attention.

It's important to know early whether you actually want to do computer science or not.  In high school or University you have a choice, when you have already studied and paid you are little more locked in.

 

As has already been stated these programs are quite easy.  Once I felt just like you, in about 1 week I understood it perfectly. There is a book called 'how to think like a computer scientist' read it.  It will help you understand how to think algorithmically.  You can be a coder, someone who simply writes code or a programmer, someone who solves problems BY writing code.  It's up to you, I think being a programmer is much more interesting.

 

Read that book (there are other versions online which are free) and I can 100% guarantee you will instantly understand much more than you did before.  And code as often and frequently as you can.  Remember, quantity is better than quality.  Constantly producing things more and more will slowly make you more efficient and will improve quality over time.  Working on one thing for months is not only boring but is also taxing on your skills and yourself.

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-8309358
Share on other sites

Link to post
Share on other sites

5 hours ago, Dessire said:

I was wondering if you ever finished the tasks you were given because i have the same problem and do not know how to do them. I was wondering if you could help me out a bit because I dont know that much went to comes to computer science... kinda failing even though I pay attention.

If you need help, the best things to do is create your own thread and explain your specific problem. There are plenty of people who can help you around here.

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-8309729
Share on other sites

Link to post
Share on other sites

10 hours ago, Mike_The_B0ss said:

It's important to know early whether you actually want to do computer science or not.  In high school or University you have a choice, when you have already studied and paid you are little more locked in.

 

As has already been stated these programs are quite easy.  Once I felt just like you, in about 1 week I understood it perfectly. There is a book called 'how to think like a computer scientist' read it.  It will help you understand how to think algorithmically.  You can be a coder, someone who simply writes code or a programmer, someone who solves problems BY writing code.  It's up to you, I think being a programmer is much more interesting.

 

Read that book (there are other versions online which are free) and I can 100% guarantee you will instantly understand much more than you did before.  And code as often and frequently as you can.  Remember, quantity is better than quality.  Constantly producing things more and more will slowly make you more efficient and will improve quality over time.  Working on one thing for months is not only boring but is also taxing on your skills and yourself.

I also recommend "Introduction to Algorithms" by Cormen, Leiserson, Rivest and Stein.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-8311119
Share on other sites

Link to post
Share on other sites

On 04/08/2015 at 8:54 PM, EpicAdom said:

For Pig Latin translation, be aware that you only move the first letter to back of the word if the first letter is a consonant (not a, e, i, o, or u) Example: part -> artpay

If the word does start with a vowel, just add "ay" to the end. Example: aardvark -> aardvarkay

 

If you're having trouble remembering how to code in Python then look over any scripts that you created while you were learning Python. You can also go partway through the codecademy course, it's a great refresher.

Codecademy teaches it as always move the first letter and add ay.

 

@Irodo_BSM Added cod in spoiler with how to do 3. as @EpicAdom suggested. I suggest you try it first and then look at my code if you really need help.

 

Spoiler

pyg = 'ay'
original = input('Enter a word:')
if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = original[0]
    if word[0] in "aeiouAEIOU":
    	new_word = original + pyg
    else:
    	new_word = word[1:len(original)] + first + pyg
    print(new_word)
else:
    print ('empty')

 

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-8312100
Share on other sites

Link to post
Share on other sites

23 hours ago, Dessire said:

I was wondering if you ever finished the tasks you were given because i have the same problem and do not know how to do them. I was wondering if you could help me out a bit because I dont know that much went to comes to computer science... kinda failing even though I pay attention.

Yeah, I wouldn't worry too much about failing, yeah, it's bad, but it's understandable if you've never had any coding experience. It exploits a different type of thinking, a very logic based one. I spent about two years in architecture, but realized, man, I don't see myself drawing, building bass models, and blueprinting only to get yelled at by the prof for some unexplainable reason (Yeah, I've seen students get grilled even if they follow what the prof told them to change the previous class..)

 

I changed over to computer engineering because I realized I liked technology more and there was less severely objective grading (At least if your code broke / if there was a better way of doing it, it made sense after it was explained).

 

It took some time for me to get good at it though, what matters more as explained above is to continually code something no matter how simple. It'll get you up to speed faster than cursing at one program for a few days.

 

I do remember having to do all of these programs in my intro to programming class though.

Link to comment
https://linustechtips.com/topic/422993-python-homework-help/#findComment-8313727
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×