Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,150 members, 7,957,288 topics. Date: Tuesday, 24 September 2024 at 10:25 AM |
Nairaland Forum / Science/Technology / Programming / Learning Programming. (my Nairaland Journal) (26308 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 syluck(m): 6:21pm On Nov 03, 2020 |
Semtu:Ok thanks. |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 6:22pm On Nov 03, 2020 |
bovage: Oh I will try that Thanks |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:25am On Nov 04, 2020 |
Hello, can someone help gimme the guidelines on coding number 1, 2 , 3 and 4 I've successfully done number 5. Thanks 1 Like
|
Re: Learning Programming. (my Nairaland Journal) by Karleb(m): 4:59pm On Nov 04, 2020 |
syluck: Google it. |
Re: Learning Programming. (my Nairaland Journal) by Etinosa1234: 6:03pm On Nov 04, 2020 |
syluck: i will help u do it later but i use java where do u get ur exercises |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 6:29pm On Nov 04, 2020 |
Etinosa1234:I got it from a pdf about python |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 6:29pm On Nov 04, 2020 |
Karleb:how please |
Re: Learning Programming. (my Nairaland Journal) by Etinosa1234: 6:54pm On Nov 04, 2020 |
syluck: I used Java... U can change it to python syntax Btw... Keep posting... I'm using it to brush up mine
|
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:15am On Nov 09, 2020 |
After much learning and practises, I came across Functions in python. And I decided to use it to solve the number (4). And it gave me two answers different from the answer proposed Cc Naijasensei Bovage semtu Karleb etinosa1234 Please I need to be cleared on this
|
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:16am On Nov 09, 2020 |
Below is the code I ran and the answers I got.
|
Re: Learning Programming. (my Nairaland Journal) by Karleb(m): 9:41am On Nov 09, 2020 |
syluck: Python's '/' always give floating point number (decimal). If you run that 10 times you might get ten different numbers, the only difference will be the numbers after the decimal. Use '//' to get a non-decimal answer instead. Try to download an introductory book to python, all these and more are discussed thoroughly there. |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:47am On Nov 09, 2020 |
Karleb:Thanks. I really forgot about '//' |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 11:38am On Nov 09, 2020 |
syluck: Hi there, my good friend. Glad to see you are making progress. For question number 4, I think you misread the question. 1. You see that dot between 47 and 48? It is actually a multiplication operator, not a decimal point. It is placed at a height that is mid height of the two numbers, rather than being placed on the baseline e.g. 47*48 not 47.48 I will apportion some blame to the authors though. 2. We can prove this by manually performing the calculation: (512 - 282) / (47*48 + 5) = 230/(2256 + 5) = 230/2261 = 0.101724900 = 0.1017 (to 4 decimal places) Let me just drop a piece of advice which will help you going forward. When you have a problem you are trying to use an algorithm to solve; understand the problem perfectly, solve it manually to confirm that you know the expected solution. In programing, when programs are tested - you provide known inputs, then you check that the program produces the expected output. 3. You don't need a function or integer division to solve this problem. 4. I also noticed you had some issues with parentheses. In Mathematics there is BODMAS (Brackets Of Division Multiplication Addition and Subtraction) to determine precedence of operations, but in programing we have PEDMAS (Parentheses Exponentiation Division Multiplication Addition Subtraction). To force a certain precedence use parentheses. //Sample program result = (512 - 282) / ((47 * 48) + 5) print(f"The result of the calculation is: {result}" ) Don't give up, you are on the right track. 8 Likes |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 11:55am On Nov 09, 2020 |
syluck: For question 1, you are simply printing the same value four (4) times. The characters (*) can be stored in a string, after which you can the print. E.g. my_string = '*******************' Print my_string the required number of times. For question 2, you are printing two (2) different patterns, which can be stored in two (2) different strings. Example pattern1 = '*******************' pattern2 = '* *' You should know what to do from here. Question 3 is slightly different. There is a clear pattern here, each new line has a new character added at the end of the string. You can simply use string concatenation (+). Example custom_string = '*' print(custom_string) custom_string = custom_string + '*' # or custom_string += '*' print(custom_string) ....you know the rest. Thanks. |
Re: Learning Programming. (my Nairaland Journal) by Karleb(m): 12:19pm On Nov 09, 2020 |
naijasensei: Python doesn't increment like that. Why don't you write it out for the dude. This write up might end up confusing him the more. |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 12:38pm On Nov 09, 2020 |
Karleb: Really? Are you sure of what you just typed? Here is proof that it works. I don't want to provide all the answers so that our friend can work, learn, and understand. 2 Likes
|
Re: Learning Programming. (my Nairaland Journal) by bovage(m): 12:53pm On Nov 09, 2020 |
naijasensei: Naijasensie has said it all. You can use the round function to approximate it to 4 d.p. round(number, ndigits) 2 Likes |
Re: Learning Programming. (my Nairaland Journal) by Karleb(m): 1:00pm On Nov 09, 2020 |
naijasensei: Apparently, I am not sure of what I typed. My bad! |
Re: Learning Programming. (my Nairaland Journal) by bovage(m): 1:02pm On Nov 09, 2020 |
Karleb: It is called augmented expression not increment. Python doesn't have the incrementing by 1 and decrementing by 1 syntax in javascript. Javascript supports augmented expression, incrementing by 1 (i++) and decrementing by 1 (i--) |
Re: Learning Programming. (my Nairaland Journal) by Karleb(m): 1:16pm On Nov 09, 2020 |
bovage: I guess you're fast to make corrections when I didn't do anything wrong. What I mean was post/pre increment/decrement. Python doesn't do that. But it does augmented expression. |
Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 2:56pm On Nov 09, 2020 |
syluck: This is a concise answer to your question. 1. One of the reasons functions exist is so you can easily vary parameters. In that sense, it's good programming to pass in arguments when defining the function which you can easily vary later on. 2. Also apply parenthesis using the BODMAS notation Finally, it seems the question asked for your answer to be in 4 decimal places. So take note of the 'round' method I called, it's an inbuilt python function that accepts two arguments, (float, no of dp)
|
Re: Learning Programming. (my Nairaland Journal) by FadaFran6Xavier: 3:10pm On Nov 09, 2020 |
Greetings. I’m interested in learning programming (coding) |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 3:15pm On Nov 09, 2020 |
FadaFran6Xavier: Greetings too. I started learning Programming using python programming language. There are many others but if you like python, then u should begin with it. Below is the link to a thread of python video tutorials. It's quite concised and easily understandable. https://www.nairaland.com/4945611/thread-tutorial-python-programming 2 Likes |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 3:17pm On Nov 09, 2020 |
Semtu: Wow, this is wow! Your coding shows how learned you are in programming. I'm yet to grasp all this algorithm in coding but I believe with time I will be able. Thanks for these. It will help me a lot |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 3:30pm On Nov 09, 2020 |
naijasensei: 1, Thanks for clarifying me on that. I thought it was a decimal point. Never knew it was a multiplication operator. 2, I will clearly work on it once more. And I really appreciate the advice. 3, A part of me told me that, but I really tried running that code using for loops, while loops, etc, I just couldn't until I came across functions then I decided to give it a try one more time and boom! it kinda gave me a clue of what I was doing. But it was giving me different answers which did not correspond with the proposed answer. Also, thanks for the advice. I will stick to them. 4, Never knew about PEDMAS. But I knew that python work according to precedence. Just that I didn't really know how that works. I really appreciate your input. Lastly, do you have a WhatsApp group or telegram channel for beginners so I could link up and be dropping my troubles as well. |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 3:32pm On Nov 09, 2020 |
Karleb: Yeah it kinda did but I appreciate it them in theory as well. Thanks still |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 10:09am On Nov 10, 2020 |
syluck: Unfortunately, I don't have links for beginners. Just keep on doing what you are doing. May I suggest studying algorithms and data structures, it will help broaden your understanding a bit. |
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 2:10pm On Nov 12, 2020 |
naijasensei: Hello bro, sorry to disturb. Please I need a better understanding of question number (9). I've tried so hard to understand what's it all about but I just keep getting a blank idea. Then, number (11) and (14)
|
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 5:23pm On Nov 12, 2020 |
syluck: Question 9 is about a sequence referred to as the fibonacci sequence. It begins with two numbers: 1, 1. Subsequent numbers in the sequence are gotten by adding the two previous numbers together. For example, the third number is: 1 + 1 = 2. The fourth number is: 1 + 2 = 3. The fifth number is 2 + 3 = 5, and so on. Your program should request for the user to input the number of fibonacci numbers they want. E.g. inputting 3 should produce 1,1,2 while inputting 5 should produce 1,1,2,3,5. One way of solving this problem is by using a loop. You will loop as many times as the user requests for, but for the first and second pass through the loop you will print(1). Question 11 is about patterns, there are two major string patterns - the one with 19 asterisks and the one with 2 asterisks separated by 17 spaces. From the diagram, the default width is 19 asterisks while the default height is 4 asterisks. If a user requests for a box that is 40 asterisks wide by 6 asterisks high, you would use a for loop to print the asterisks 40 times in 6 passes - a nested for loop. E.g. for i in range(1, height+1): for j in range(1, width+1): Let me see what you will come up with. 1 Like |
Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 5:29pm On Nov 12, 2020 |
syluck: def sequence_function(num): if num==0: return num+1 elif num==1: return num else: return sequence_function(num-2) + sequence_function(num-1) len=int(input("Enter len of terms: " ) for i in range(len): print(sequence_function(i), end='\t') This is the answer to your number 9, improve on it by adding constraints against negative numbers. If a user enters a negative number with the code above, it'll produce an error. Use a simple if statement to make sure that doesn't happen. 1 Like |
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 6:07pm On Nov 12, 2020 |
syluck: Question 11 proposed solution 1 Like
|
(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. 94 |