New to Coding! Intro to bytes help needed! Python! Pybytes!

Question:

I am incredibly new to coding and also currently self taught. Learning python and am in desperate need of assistance so I can help my younger cousin with homework! We are basically learning together and are both stumped on a particular assignment with if/then statements. Help understanding what we are doing wrong and what the assertion error means would be amazing!
I’m not completely sure if I posted the snippet of code correctly so any helpful tips and hits would be welcome!
Repl link: https://replit.com/@jroman3/Ifthen-practice#main.py

def check_payday(payday):
       if check_payday == "date":
           print("Time to pay rent.")
       else:
           print("Keep calm and eat two minute noodles.")

The program you attracted has no output, could you at least configure it to have an example output please?

2 Likes

As it is an assignment that I am trying to help on, I’m honestly not all too sure what I’m looking for. But the assignment states the following:

Within the function check_payday() below:

  • Write an if statement that checks to see if “date” is equal to the string “payday”.
  • If it is, then print “Time to pay rent.”
  • If it isn’t equal to payday then print “Keep calm and eat two minute noodles.”
  • Hint: Remember your indentation!

I feel like the error may be in line 1 of the code but again I’m not sure! Thank you for such a quick reply! I’m sorry that I’m a noob and don’t fully know what you need in order for you to best help haha

Welcome to the forums, @jroman3!

I really don’t think you should be posting your school / uni assignments to this forum. It’s not right to expect others to do the work for you and your tutor will not understand how to help you if you are submitting work from someone else.

Please feel free to post questions that will help you understand the building blocks of programs, but don’t post tasks again.

1 Like

Okay, a nudge (not the answer, this is an assignment), you shouldn’t be checking if the function is equal to “date”

4 Likes

I actually am the tutor. I get paid to assist kids with school work (mind you I don’t get paid to help my cousin), however I have been recently asked to help with coding. While I explained to my cousin’s parents that I am not equipped for that, they asked if I could possibly learn along with him and help with the assignments that he gets stuck on/has to redo.

While I fully understand and respect your opinion, I would not be posting for this help if it were my own homework assignment. I work two full time jobs outside of tutoring for family and friends, and I am now being asked to help with something that I know next to nothing about. Instead of scrutinizing someone for their situation (which you are not fully aware of) I would appreciate those who are willing to assist and aid me. I am doing my best here. I want my cousin to pass this class, but in order to help him I have to receive help first. While helping him I thought it would be cool to try and learn something new and challenging myself, but it’s getting to a point where I need help too.

1 Like

Thank you for the nudge!! As I just stated, it’s not an assignment for me haha I tutor my cousin (and other kids) and was recently asked to help with coding. I’m the tutor that needs a tutor hahaha but I swear I’m not trying to directly give my cousin the answer, but I can’t help him if I don’t even know waht it is

1 Like

ok, sorry, it was a pre-made reply, that sounded kind of mean. I will ask a mod if it is ok to answer a question like this.

I didn’t mean for it to come off as mean. I am personally frustrated with this assignment, myself for not figuring it out, and the overall situation. When I finally reached out to the great wide web for help, I really didn’t appreciate having a reply that was basically questioning my dignity.
All I’m asking for is help – I read the guidelines, I know you aren’t supposed to ask for answers here if you’re working on homework or an assignment. While the question is in regards to a school assignment, I figured it would be okay as it is not my assignment and I am the tutor. I should have made that clear from the start, that was definitely my mistake.

Again, my apologies if you think I was being mean. Hopefully you can get a better understanding of where I’m coming from.

1 Like

I mean my reply was mean, not yours XD. We can still give tips in the right direction.

1 Like

omg totally my bad!! I was afraid you thought I was being mean and then I was like “oh no” let me explain myself better :stuck_out_tongue:

so, it’s my function that is incorrect? I’ve tried a couple of combinations of different wording but still to no avail.

1 Like

In programming wording is usually as you or someone else define it. So right now, you have the wrong name, and you already wrote down the right name :slight_smile:

hmmmm, okay, that’s starting to make more sense! I think haha

So I already have the correct name written down in my code? But, I also have a wrong name entered which is creating an error?

1 Like

I’m going to try to make your current code like a story, maybe that will help :stuck_out_tongue:

Say you have a machine called “check_payday”.
You input a piece of paper we’ll call “payday”.
The machine does one of two things:

  1. If the machine “check_payday” is equal to the words “date”, the machine tells you it’s payday
  2. Otherwise the machine tells you to enjoy some two minute noodles.

Also note that if nothing is put into the machine, the machine will break.

3 Likes

This is your code:

Your if statement is this: if check_payday == "date":. There are two things wrong with this. You should double check what you’re testing if the string is equal to, but more importantly, what is check_payday? Look at where and how check_payday is defined. Remember you want to check if the parameter in the function is equal to a certain string. :smile:

1 Like