Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,349 members, 7,957,926 topics. Date: Wednesday, 25 September 2024 at 02:50 AM |
Nairaland Forum / Science/Technology / Programming / Learning Programming. (my Nairaland Journal) (26319 Views)
Some Months Into Programming, My Excruciating Experience. / Avoid The Hard Ways Of Learning Programming / Help I"m Loosing Intrest Fast In Learning Programming. (2) (3) (4)
(1) (2) (3) (4) (5) (6) (7) (8) (9) (Reply) (Go Down)
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 6:39pm On Nov 12, 2020 |
syluck: Proposed solution to Q9: 1 Like
|
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 5:23am On Nov 15, 2020 |
naijasensei:Thanks for this input. I won't lie, it took me a while before understanding this |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 5:32am On Nov 15, 2020 |
syluck: No shame in that. Some of the concepts are a bit abstract, so it might take a while to understand. Whenever you get stuck, just take your time, relax, do something else, then return to the problem. 1 Like |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 8:21am On Nov 15, 2020 |
naijasensei:Okay. |
Re: Learning Programming. (my Nairaland Journal) by Iconstar: 11:28am On Nov 15, 2020 |
syluck: |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 8:00pm On Nov 20, 2020 |
Came across this and I tried running the code. Number 2 and 3 precisely. I'm having problem on both. In Number 2, I ran the code according to the best of my knowledge but the only issue is having both the Fahrenheit and celcius on both (uppercase, lowercase, first letters both capital and small) Then for number 3, I just need to understand how to implement the -273.15 when coding. Thanks
|
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 9:33am On Nov 21, 2020 |
syluck: Why are you using the eval function in your code? |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:55am On Nov 21, 2020 |
naijasensei:According to the pdf I'm using to work on, it has eval throughout. I kinda decided to use it though |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:58am On Nov 21, 2020 |
I'm just glad I'm improving day by day
|
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 10:04am On Nov 21, 2020 |
syluck: Drop it, you don't need it. Try the following for Q2
|
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 10:15am On Nov 21, 2020 |
syluck: For question 3, you are to use if...elif...else blocks If you have a variable, temp, pointing to where the temperature in °C is stored. Then: Point of note, I am only showing this to give you an idea. In practice, in a program, be careful when comparing floating point (decimal) numbers. Floating point arithmetic is not as straightforward as integer arithmetic.
|
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 10:27am On Nov 21, 2020 |
naijasensei:Does this automate the 273.15 to -273.15? Cos that's really my problem. How to run the code inserting the -(minus) operator |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 10:38am On Nov 21, 2020 |
syluck: My bad, put the negative sign (-) before the number -273.15. (-) is both a unary and binary operator. 1 Like |
Re: Learning Programming. (my Nairaland Journal) by Vecto(m): 4:14pm On Nov 21, 2020 |
naijasensei: Sorry do you code on mobile? |
Re: Learning Programming. (my Nairaland Journal) by Vecto(m): 4:16pm On Nov 21, 2020 |
syluck:Well done bro. Coding on mobile can be quite stressful, eh? What pdf are you using btw? |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 5:09pm On Nov 21, 2020 |
Vecto: Thanks bro. Here is the pdf name 1 Like
|
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 5:13pm On Nov 21, 2020 |
Vecto: Yes, most times. Can't be carrying my pc all the times |
Re: Learning Programming. (my Nairaland Journal) by Vecto(m): 5:23pm On Nov 21, 2020 |
syluck:Thanks. 1 Like |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 6:41pm On Nov 21, 2020 |
Vecto: No, I don't. I just used my mobile to illustrate some stuff. I code on my laptop. |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 6:42pm On Nov 21, 2020 |
syluck: Say what? You're using a 2012 material? 2 Likes |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:41pm On Nov 21, 2020 |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 8:43am On Nov 22, 2020 |
syluck: Think like a computer scientist. Automate the boring stuff with Python. Make sure you get the latest editions. Even the one you are using, I suspect there might be a newer version. 5 Likes |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 2:53pm On Nov 26, 2020 |
naijasensei:Bro, on god sometimes the simplest algorithms are the hardest to code Please can you help me out on number 10 and 12
|
Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 3:57pm On Nov 26, 2020 |
syluck: I'll give you hints for number 10, you learn better my figuring things out yourself. You'll need to collect 10 inputs from the user by calling input() through a loop. Outside the loop, create an empty list then append each input to the list while the loop is still valid. Once you've collected the inputs to a list, you can easily play with the python list by calling sorted(). This will sort the list elements in ascending order. Meaning that indexing the first element of the list would be the lowest since the values are sorted while the last would be the highest. To find the average, you can sum the list then divide by the len. Apply similar logic to the rest. For the second part, this is one way to work through it. import random score = [ ] number=random.randint(1,11) trials=5 while trials>0: ```indent```guess=int(input('guess the number between 1 to 10: ') ```indent```if guess==number: ```indent``````indent```score.append(10) ```indent```else: ```indent``````indent```score.append(-1) ```indent```trials-=1 print(sum(score)) 3 Likes |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 5:34pm On Nov 26, 2020 |
Semtu: Nice, great work. For Q12 though, I believe score shouldn't be a list, rather it should be of type int. So: score = 0 number = random.randint(1,10) #different from random.randrange(1,11) Because of this: score.append(10) should be score += 10 score.append(-1) should be score -= 1 Thanks. 1 Like |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:52pm On Nov 27, 2020 |
Semtu: Thanks bro....my head be so heavy this days cos of running codes.... |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 5:41pm On Nov 28, 2020 |
naijasensei: Bro, there's this python concepts I really need to understand how it works.... I'll list then below: 1: for i in range (2, prompt+1): Here, I know "prompt" could be a variable where a value is assigned to.....then, (2) is where we want the loop to start from.... My difficulty is understanding what +1 after the prompt stands for.... Like the example above I listed is used when running a code for "divisors of a number*... 2: for i range(1, num+1): Indent""""""""factorial = factorial * i Here, the +1 appears again.... But this time around it's the "factorial * i".... Pls I need to understand this concept really good..... Lastly: 3: for i in range(1, prompt+1): Indent"""""""""if(prompt %i ==0) Indent"""""""""s += i Here, I understand what prompt is, %i is, ==0 is, and s is... The problem is, "+=". I still don't understand vividly what's that all about...in short, u can explain the whole concept "s += i" to me please.... PS: i know that + is an addition operator * Is a multiplication operator = a equal sign operator ( mostly used to assign values to variables and vice versa) |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 5:42pm On Nov 28, 2020 |
Hey, please anyone can help out... Bovage Semtu Karleb Thanks |
Re: Learning Programming. (my Nairaland Journal) by Karleb(m): 6:18pm On Nov 28, 2020 |
Let say x has an initial value of 2. When you do x += 2 it a short hand for x = x + 2, which will give you 4. That means x = x + 2 'and' x += 2 are thesame thing. You can substitute the addition sign for any other arithmetic sign in python. x = 4 x *= 4 #16 x //= 2 #8 x -= 3 #5 x %= 2 #1 x /= 1 #1.0 1 Like |
Re: Learning Programming. (my Nairaland Journal) by Karleb(m): 6:28pm On Nov 28, 2020 |
In python for loop, the range function doesn't loop to the end of the value naturally, to enable it do this, you have to add 1 the value. range(1, 4) will print out. 1,2,3 in a loop. So to let it loop to 4 you'll add 1 to 4 to make it 5. That is, range(1, 4 + 1) will print 1,2,3,4. That is thesame thing as range(1, 5). In the case where the integer is stored in a variable is when you see something like range(1, myValue + 1). myValue = 4 for i in range(1, myValue + 1): print(i) That loop will print 1,2,3,4. I think this range thingy is a bug turned feature in python because when you loop through a list, you don't have this problem. |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 6:31pm On Nov 28, 2020 |
syluck: Q1 - First understand what range() does. range(start, stop, step). The range function produces values from the start value, upto but NOT INCLUDING the stop value. That is; for i in range(1,10) supplies i with values 1,2,3,4,5,6,7,8,9. Assuming prompt = 10, and I want a range of values from 1 to 10 (10 inclusive), instead of range(1, prompt) I would rather use range(1, prompt + 1) Q2 - factorial = factorial * i is a programming concept you will see a lot of. It means multiply the value referenced by "i" with the current value referenced by "factorial", then let the new value referenced by factorial be (factorial * i) Q3 - s += i is the same as s = s + i, same explanation as in Q2 s *= i is the same as s = s * i, s -= i is the same as s = s - i, and so on. 1 Like |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 8:24pm On Nov 28, 2020 |
Karleb:I appreciate this thanks.... |
(1) (2) (3) (4) (5) (6) (7) (8) (9) (Reply)
Why Do Self Taught Programmers Over Exaggerate / How To Create A Shipping Tracking On Website.? / Build A Mobile App Without Knowing Any Programming Language or line of code.
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 65 |