Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,545 members, 7,809,005 topics. Date: Thursday, 25 April 2024 at 08:58 PM

Learning Programming. (my Nairaland Journal) - Programming (4) - Nairaland

Nairaland Forum / Science/Technology / Programming / Learning Programming. (my Nairaland Journal) (25420 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): 8:25pm On Nov 28, 2020
Karleb:
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



Concised and informative...

I appreciate your help
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 8:25pm On Nov 28, 2020
naijasensei:


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.

Thanks bro...

1 Like

Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:57am On Dec 17, 2020
Ok guys, I'm stuck in the while loop.

Want it to print exactly what the for loop does

Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 1:14pm On Dec 17, 2020
syluck:
Ok guys, I'm stuck in the while loop.

Want it to print exactly what the for loop does

Your print statement is not under the while loop.
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 1:39pm On Dec 17, 2020
Semtu:


Your print statement is not under the while loop.
Still wouldn't give me what the for loop would gimme
Re: Learning Programming. (my Nairaland Journal) by realman42: 2:46pm On Dec 17, 2020
Well-done
Start a project immediately
U will learn faster
Browse beginners projects
Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 4:20pm On Dec 17, 2020
syluck:

Still wouldn't give me what the for loop would gimme

Two things are wrong:

1. You have to print str for each iteration as you've done for the for loop, which is print(str[i])
2. The print statement should come before i+=1

2 Likes

Re: Learning Programming. (my Nairaland Journal) by KingAbdulazeez: 4:33pm On Dec 17, 2020
Semtu:


Two things are wrong:

1. You have to print str for each iteration as you've done for the for loop, which is print(str[i])
2. The print statement should come before i+=1
This is giving annoying while loop
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 4:42pm On Dec 17, 2020
KingAbdulazeez:

This is giving annoying while loop
Lol, u don't like using while loop?
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 4:45pm On Dec 17, 2020
Semtu:


Two things are wrong:

1. You have to print str for each iteration as you've done for the for loop, which is print(str[i])
2. The print statement should come before i+=1
Thanks. It worked
Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 4:46pm On Dec 17, 2020
KingAbdulazeez:

This is giving annoying while loop

I don't get
Re: Learning Programming. (my Nairaland Journal) by KingAbdulazeez: 5:12pm On Dec 17, 2020
Semtu:

I don't get
the loop continues and didn't stop until I interrupted it.
Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 5:16pm On Dec 17, 2020
KingAbdulazeez:

the loop continues and didn't stop until I interrupted it.

To avoid an infinite loop, you must always increment i (i+=1) till the condition which is (i<len(str)) can no longer be satisfied
Re: Learning Programming. (my Nairaland Journal) by KingAbdulazeez: 5:20pm On Dec 17, 2020
Semtu:


To avoid an infinite loop, you must always increment i (i+=1) till the condition which is (i<len(str)) can no longer be satisfied
I get it thanks for your time.
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 1:04am On Dec 18, 2020
realman42:
Well-done
Start a project immediately
U will learn faster
Browse beginners projects
Thanks man. But I need to finish up dictionary and text files
I'm still learning

1 Like

Re: Learning Programming. (my Nairaland Journal) by syluck(m): 2:26pm On Dec 18, 2020
Q. Write a program that asks the user to enter a password. If the user enters the right password,
the program should tell them they are logged in to the system. Otherwise, the program
should ask them to reenter the password. The user should only get five tries to enter the
password, after which point the program should tell them that they are kicked off of the
system.

I used both loops, for and while loop
See below

Re: Learning Programming. (my Nairaland Journal) by KingAbdulazeez: 2:56pm On Dec 18, 2020
where do you find project like this.?
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 3:08pm On Dec 18, 2020
KingAbdulazeez:
where do you find project like this.?
I'm using a pdf that teaches the basics of Python and gives exercises to work though it's old(2012 edition) but I just like it
Re: Learning Programming. (my Nairaland Journal) by KingAbdulazeez: 3:35pm On Dec 18, 2020
syluck:

I'm using a pdf that teaches the basics of Python and gives exercises to work though it's old(2012 edition) but I just like it
can you share the PDF or the link to download it.
Re: Learning Programming. (my Nairaland Journal) by syluck(m): 4:24pm On Dec 18, 2020
KingAbdulazeez:

can you share the PDF or the link to download it.

www.brianheinold.net › pythonPDF
A Practical Introduction to Python Programming - Brian Heinold

Search 'python pdf' on Google. Scroll down to where you'll find what I posted above. Don't bother clicking on that link.
Re: Learning Programming. (my Nairaland Journal) by KingAbdulazeez: 5:33pm On Dec 18, 2020
syluck:


www.brianheinold.net › pythonPDF
A Practical Introduction to Python Programming - Brian Heinold

Search 'python pdf' on Google. Scroll down to where you'll find what I posted above. Don't bother clicking on that link.
thanks
Re: Learning Programming. (my Nairaland Journal) by naijasensei: 6:11pm On Dec 18, 2020
syluck:
Q. Write a program that asks the user to enter a password. If the user enters the right password,
the program should tell them they are logged in to the system. Otherwise, the program
should ask them to reenter the password. The user should only get five tries to enter the
password, after which point the program should tell them that they are kicked off of the
system.

I used both loops, for and while loop
See below

Great to see you are making progress. However, always remember proper indentation in your Python code, else you will get logic errors in your code (if you don't encounter syntax errors first).

1 Like

Re: Learning Programming. (my Nairaland Journal) by naijasensei: 6:12pm On Dec 18, 2020
KingAbdulazeez:

thanks

You can also search for "Think like a computer scientist 3", search for the Python version.

2 Likes

Re: Learning Programming. (my Nairaland Journal) by Cherez: 5:57pm On Dec 19, 2020
naijasensei:


Hi, glad to see you are getting good mileage on your journey. Not trying to come across as snobbish, but I just want to correct an impression you have.
Variables are not containers, a variable is more like a label that points to a value. Values (integers, floats, boolean, strings) are stored in memory, so a variable points to a memory location. Don't just take my word for it, here is proof. There is a function in Python called identity - id(). id() is used to return the memory location of a particular value.

Exercise
Create two or more different variables, then assign the same value to each variable.

my_var = 34
another_var = 34
third_one = 34

print(id(my_var))
print(id(another_var))
print(id(third_one))

The value returned should be the same for the three print functions. The actual value will also depend on the particular system you run the code on.
Hope I have not confused you though, because this concept is very important.
The author is right;
Variables are temporary data stores
Re: Learning Programming. (my Nairaland Journal) by Nobody: 6:00pm On Dec 19, 2020
Following ur progress op.

looking at people's code and trying to understand it is the best way to learn imo.

I remember reading udemy-dl on GitHub and I remember reading this one too https://github.com/bocadilloproject/bocadillo
Learnt how to use slots in python from that project.

Some python tips for you.

Install ipython on ur command line for easy code completions.

Use tab to trigger code completions on ipython. (Works on jupyter notebook too)

Inspect using dir()

1 Like

Re: Learning Programming. (my Nairaland Journal) by Getsaved(m): 6:11pm On Dec 19, 2020
syluck:
Hustle till you no longer need to introduce yourself-

Deriving some intensive understanding from the above mentioned, I've come to realize that I need to keep pushing forward in my daily activities. To keep pushing forward till that moment when I don't need to stand up infront of someone or group of persons to introduce myself in a manner that will be awkward to my audience. A manner in which my audience will have that indifference feeling about me and wondering who am I and my mission. So in order not to allow this scenario come to play, I've decided not to be complacent.

A complacent satisfaction with the present knowledge is the chief barrier to the pursuit of knowledge - B H Liddell Hart.

In pursuit of more knowledge, I decided to involve myself into programming. This, I believe is a step to a milestone of success I will achieve.

I developed interest in programming at a time but later lost interest because to be a successful programmer you need a good mentor. If I can have one here that can guide me I am willing to learn and become a programmer. Can you help?
Re: Learning Programming. (my Nairaland Journal) by dhtml6(m): 6:14pm On Dec 19, 2020
Just in case you are trying to learn website development or programming especially for a beginner. You can send me a message.
Re: Learning Programming. (my Nairaland Journal) by Wartsnigeria: 6:25pm On Dec 19, 2020
syluck:
One important thing I learnt from again is that, any variable with two UNDERSCORES at the beginning and two at the end shows how important it is and shouldn't be altered.


This is wrong sir, variables that starts with underscores are priavate variable hence you need to access them from methods and not directly, when you get to object oriented part of programming, you will understand. For now disregard them and don't use them while learning the basics.
Re: Learning Programming. (my Nairaland Journal) by adeniyi3971(m): 6:40pm On Dec 19, 2020
I started full stack dev on Microverse too! Right now I’m still at the pre application stage via Odins project!


Learning HTML
CSS
Java script
And I’m loving it!

Hopefully we’ll be able to work on a project together!
For now, Let me go back to my laptop! wink

2 Likes

Re: Learning Programming. (my Nairaland Journal) by MDBrand: 6:44pm On Dec 19, 2020
syluck:
So I tried practising on users input after much concatenations and formatting.
Are you attending classes or video tutorials?
Re: Learning Programming. (my Nairaland Journal) by thatNigerian: 6:58pm On Dec 19, 2020
syluck:
So yesterday, I was able to decipher and crack open what command line is all about. Creating new directories and files using command line.

Judging by the command line guide, I know what these performs,

pwd
cd
cd .
cd ..
ls
-a
-l
rm
rm -r
mkdir
touch
rm
Etc

What learning resources do you use?
Re: Learning Programming. (my Nairaland Journal) by rastaxarm(m): 7:16pm On Dec 19, 2020
Available

(1) (2) (3) (4) (5) (6) (7) (8) (9) (Reply)

Whats The Best Laptop For Programming? / Best Operating System For Programming! / Testing Programmers: Puzzles Or Web Applications?

(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. 39
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.