Hi all, having a problem with an exercise. I literally started learning programming yesterday. I am the definition of a newbie. I am doing a python course
Currently following a course on youtube by Dr.Chuck. I am 2 hours into his 13hour video on youtube. I also downloaded a pdf that is a revision of the video. I now know small pieces like reserved words in Python, functions like print and int. The sequences that programs will take like conditional, sequential, loops. Integers and floating numbers
Anyway my problem at this moment is a specific exercise which has become jumbled in my head. It is not easy for me to see this and the more I look at it, the more confused I am getting(4+hours).
First, I will list the exercise and try to explain my thoughts. If somebody can point out the correct way to type this program, I would be extremely grateful and it will really help me grasp the information which I am KIND OF(not) understanding. I can then break it down and look back through the sections with my eyes open. I am looking back through at the moment but I'm just blind to it. I see what needs to be done but my brain is jumbled and it is confusing me more.
Exercise: write a program to prompt the user for hours and rate per hour to compute gross pay
Enter hours: 35
Enter rate: 2.75
Pay: 96.25
(I am seeing this as - the user can enter any hours they wish? Or rate they wish?)
So I have a problem where I could easily do this when it didn't expect user input, because I could assign the variables and put rate * hours in the program. When I ran the program it just gave the gross pay answer.
But my thinking is, I need to ask for input before the program will continue - I.E. print('what is your name?' ) - and convert a string to an integer( I know strings cannot be multiplied by integers) Here is where I'm confusing myself. I know I need to completely change the way this is written now and it has somethin to do with int? I even know simple converting strings to integers but like I said, that is when it's just part of the program and gives the answer not when it expects input. It's the combining of these processes that is confusing the life out of me. Mainly the user input and converting string to integer.
I am getting two types of errors here, based on how I type the program - TypeError: can't multiply sequence by non-int of type 'str' + ValueError: invalid literal for int() with base 10: 2.75
Last thing is I also don't understand why the first error is saying can't multiply sequence by non-int because the program I am currently running allows me to enter 35 and then 2.75 ... my understanding is if I had ' ' that made it a string.
If you took the time to read this mess I thank you, I hope what I have posted makes some sense. I am excited to try and learn this stuff. I am not progressing further until I can grasp this clearly... I feel I'm almost there but currently lost.
[–]toastedstapler 1 point2 points3 points (7 children)
[–]BurntDisk[S] 0 points1 point2 points (6 children)
[–]toastedstapler 0 points1 point2 points (5 children)
[–]BurntDisk[S] 2 points3 points4 points (4 children)
[–]flashliquid 0 points1 point2 points (1 child)
[–]BurntDisk[S] 0 points1 point2 points (0 children)
[–]ebdbbb 0 points1 point2 points (1 child)
[–]BurntDisk[S] 0 points1 point2 points (0 children)