Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,944 members, 7,821,306 topics. Date: Wednesday, 08 May 2024 at 11:12 AM

Naijasensei's Posts

Nairaland Forum / Naijasensei's Profile / Naijasensei's Posts

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (of 19 pages)

Programming / Re: My PHP Code Run Locally On XAMPP But Showing Syntax Error Online by naijasensei: 10:18am On Jan 31, 2021
Akprof:
What can be making my php code to be running online but showing syntax error online?

Please try uploading a screenshot of said syntax errors. These sort of issues can arise for so many different reasons. One such reason, as some have kindly pointed out, could be due to differences between your local XAMPP environment and the environment of your online server.

1 Like

Programming / Re: Computer Science by naijasensei: 10:10am On Jan 31, 2021
wristandbands:
This is for Computer Science student/graduate, any an all opinion are welcomed ... would appreciate if a Baze University Computer Science student /graduate would comment.

So about a take a computer training program (mind you I'm coming from an economics background) I would like to know which one is more suitable than the other.

1: The picture : is for the first school

2 : the web link is for the second school

Please kindly go through them and let me know which is okay.

Weblink for the second school

http://aptech-nigeria.com/computer-professional-courses-and-certification

This seems to be some sort of web development / computer programming training, and not Computer science. To be brutally honest with you, those course duration dates are highly unrealistic. The only people that will benefit from those courses are those who are not complete beginners.
Look at the C++ training, it mentions four(4) weeks as the course duration - this is a huge joke. Fours weeks is not even enough for some people to learn easier languages like JavaScript and Python. Am I saying no one can do it? No, however the average student will struggle mightily. Even if you enlist for these courses, have it at the back of your mind that you will still have a lot of ground to cover after the training.
If possible, request for the training school's scheme of work - so that you can compare it with other courses online. Finally, make sure you choose the courses that suit the path you want to follow. For example, web development, mobile development, database administration, etc.
As always, the views expressed herein are solely mine, and they are not gospel. Thanks.

2 Likes

Programming / Re: Thread For Nairaland Algorithm Questions by naijasensei: 8:36pm On Jan 23, 2021
cixak95211:
Ques 3:
What is the problem with this block of code?
What is the fix?


From the way switch statements work, the expression within 'switch(expression)' is evaluated only once. That is this arrow function will always return either 0 (whenever amount is zero, or amount is undefined) or 50 for all other values because it ignores the comparison expressions in the two case statements following the first one.
There are two possible solutions I can think of:
1. Use an if...else if...else construct.
2. Make the expression within 'switch(expr)' to always evaluate to true, then check your expressions within your case statements.

const calculateFee = (amount) => {
switch (true) {
case amount === 0:
case amount === undefined:
return 0;

case (amount > 0 && amount <= 5000):
return 10;

case (amount > 5000 && amount <= 50000):
return 25;

default:
return 50;
}
};

const calculateFeeAlt = amount => {
if (amount === 0 || amount === undefined) {
return 0;
} else if (amount > 0 && amount <= 5000) {
return 10;
} else if (amount > 5000 && amount <= 50000) {
return 25;
} else {
return 50;
}
};

Programming / Re: Thread For Nairaland Algorithm Questions by naijasensei: 6:57pm On Jan 23, 2021
cixak95211:


* push
line 23 is not necessary
as you can return the increased length on line 22.

* unshift
line 42 is not necessary
as you can directly assign this.stack to [value, ...this.stack]

depending on some school of thought, it's best to outline each line seperately,
but you'd be wasting memory declaring variables that are really not necessary
a smart code editor e.g. any of the JetBrains family, would have also warned you about it.

Its amazing we have smart minds here, so why did y'all allow this place to be overran
by some "website for 20k" minds?

I agree with not using the additional variable 'temp' on line 42. As for line 23, the redundancy is intentional.

As for the website for 20k guys, I reserve my comments - for now.
Programming / Re: Thread For Nairaland Algorithm Questions by naijasensei: 2:32pm On Jan 23, 2021
cixak95211:
Question:

1. Design an algorithm(s) for the following array operations: "push, pop, shift, unshift" using object oriented programming practices.
2. Design an algorithm that will find the longest common subsequence between two arrays, plus the time complexity for your solution.

Question 1 only:
1. Kotlin
2. Kotlin (continued)
3. Javascript

Programming / Re: Thread For Nairaland Algorithm Questions by naijasensei: 2:23pm On Jan 23, 2021
Karleb:
Question. Write a function that determines if a word is a palindrome.

Hint: Palindromes are words that has same spelling backward and forward.

E.g madam, racecar.

1. Kotlin
2. Python

Programming / Re: Thread For Nairaland Algorithm Questions by naijasensei: 6:10am On Jan 21, 2021
Donpre:

Beautiful but....

Nice observation. There are several things at play here. Your Python interpreter stripped off the leading zero on your text input immediately you cast your input to type int, you can confirm this. If you try to supply an int with a leading zero, your program will not run because it is not a valid int.
The main issue I see is, if zero(0) is the last digit on the integer you inputed - it will not appear in your reversed integer. This is because, you will end up having zero as your first integer digit - which is not valid.
Therefore, when this solution is used - any integer input that has a zero as the last digit will not produce an integer output with a leading zero.
Programming / Re: Thread For Nairaland Algorithm Questions by naijasensei: 9:49pm On Jan 20, 2021
Deicide:
The method used, though language used also play an important role.....You could also use module arithmetic to solve this, I think that's the fastest way to solve this.

Modulo arithmetic, using the remainder of a division combined with the quotient. Because, given any integer, n:

n / divisor = quotient * divisor + remainder.

If 10 is our divisor (because it will preserve the number but shift the decimal point to the left, 123/10 = 12.3):

Then, n / 10 = quot * 10 + rem. For example, 12345 / 10 = 1234 * 10 + 5. If we divide by 10 repeatedly until we get zero and store the remainder in a variable during each iteration, we can successfully reconstruct the number in reverse by adding the remainders while remembering to multiply each digit by their corresponding powers of 10.

reversedNumber = (((rem1 * 10 + rem2) * 10 + rem3) * 10) + ... + remn

Image1 - Python
Image 2 - Kotlin

Programming / Re: Thread For Nairaland Algorithm Questions by naijasensei: 4:39pm On Jan 20, 2021
Deicide:
Correct but this code would be very slow & again Python is is a very slow language

How about Kotlin then, with two(2) different implementations.

Programming / Re: Thread For Nairaland Algorithm Questions by naijasensei: 12:59pm On Jan 20, 2021
Deicide:
Question
Given an input number n, you are to reverse the number.
E.G
Input - 12345
Output - 54321

Input - 18352
Output - 25381

Input - 2
Output - 2

number = 12345

def rev_number(num):
num_str = str(num)
num_str = num_str[::-1]
out_num = int(num_str)
return out_num

print(rev_number(number))

1 Like

Programming / Re: Thread For Nairaland Algorithm Questions by naijasensei: 12:48pm On Jan 20, 2021
Brukx:
Lemme just drop this here

Question
Write a function that takes user input. The input must be either 7 or 4. If the input is 4, the function should return 7. If the input is 7, the function should return 4. Do not use if or else statements. Do not use exceptions.

my_input = input("Enter a number, either 4 or 7: "wink

my_output = {'4': 7, '7': 4}

def is_it_4_or_7(my_var):
return my_output.get(my_var)

print(is_it_4_or_7(my_input))

1 Like

Programming / Re: My First HTML Page by naijasensei: 12:00pm On Jan 20, 2021
Telegram234:
I just finished learning HTML after using YouTube, tutorialspoint and some PDF.
Hoping to go to CSS course later.
Rate my first work grin angry cheesy

Nice job. I have a few pointers though.

1. You nested an 'hr' element within an 'h1' element. While you are free to do this, it is not semantically recommended. By the HTML standards, heading elements (h1, h2, h3, h4, h5, h6) are not supposed to have child elements. Also use heading elements for semantic purposes, not presentation purposes.
2. You didn't use the 'hr' element properly. The 'hr' element is an empty element, so it has no content or closing tag - just an opening tag.
3. Similar issue with your 'br' element, it is also an empty element.
4. The 'big' element is a deprecated element, it is no longer recommended for use.
5. The 'strike' element has also been deprecated, it is not valid HTML5. Use the 'del' or 's' elements instead.
6. Be careful how you use 'b', 'em', 'strong', and 'i' elements. Make sure you use them semantically and not for presentation purposes, especially the 'em' and 'strong' elements.

2 Likes

Programming / Re: Learning Programming. (my Nairaland Journal) by naijasensei: 11:44am On Jan 12, 2021
syluck:

Bro, I want to ask you this question, it's been bothering me for a while.

I'm on the edge of becoming a pythonista real big. One big question I'll like an answer from a second/third party is, After Python what next?
Like, after I'm done learning python, what should I involve myself with next? Is it learning frameworks like node.js, PHP, JavaScript, Django etc.
For the record, I solely learnt python so that I can be creating websites(website like Spotify, pandora, audiomack, onlyfans etc) and apps. Now, I came across things like AI, and cyber security which I'll like to be an expert in. So I'm just confused on what next I should indulge in.. I'll really like an elaborated and explicit explanations on this.
Thanks

Cc:
Karleb
Semtu


Karleb:
@syluck

Be candid with yourself, there are a lot of things you've not covered in python and many of these are what you'd encounter in other programming languages.

So it's better you pick a good python book and read it extensively before thinking of moving to the next big thing, you can't jump guns with programming. If you do, you'd still go back and relearn what you skipped.

AI, cyber security and web development are three different routes.

After honing python basics, then the next thing to learn is Django. It's python most popular web development framework.

I agree with what @Karleb said. Try and focus on one thing so that you can master it. You mentioned web development, which is a path or route. AI, Cyber Security, Machine learning, Mobile App development, and Data Science are some other paths.
To continue using Python for web development, there are two major frameworks you need to get familiar with - Django, and Flask. Django is a full fledged, everything (batteries) included framework, that can be used to develop all manner of web apps. Flask on the other hand is a micro framework, which is best for developing APIs.

In the web development domain, there are two(2) main areas - front end development, and back end development. Back end development takes care of interactions with your web server, interactions with your database server, and interactions with your server environment. Front end development basically has to do with things that happen in the browser, and the User Interface.
Python is used for back end web development, other popular alternatives are PHP and NodeJS. I personally use PHP for web development for two(2) reasons: it was the first web development language I learnt, and web development is PHP's primary domain. I won't bore you with pointless arguments for and/or against Python, PHP, and NodeJS. I believe in using the best tools for the job, and I use whatever gets the job done.
To round off your skills in web development, you will need to get a solid grasp of HTML, CSS, and Javascript for front end development. You can then decide which type of development you prefer, or you can combine the two to become a full stack developer.

4 Likes

Programming / Re: Help Me Please. by naijasensei: 2:17pm On Jan 08, 2021
spartan117:

I don't really see anything wrong in what he posted bro.

I for example started programming on my phone because I didn't have a laptop. I was able to learn the basic syntax of HTML, CSS,JavaScript, SQL and Python right on my phone with the sololearn app back then.

I applied for a bootcamp and was given a webpage with fairly complex styling (for a beginner) to clone as a requirement for admission. I was able to build the website on sololearn, then copied the code into a text editor and saved it with the appropriate filename, downloaded winrar from playstore to compress the folder and upload to Dropbox for submission. Did this all with a phone!

I actually passed and got admitted to the program. This happened some years back and I still sometimes go back to look at that webpage, with a smile.

What I'm saying is don't discourage the op these are his days of little beginning and it will payoff if he continues.


Wow, that is impressive. As a wise person once said, if you cannot alleviate someone's pain, do not add to it. If you cannot put out a fire, don't add petrol to the fire. If you cannot help a person; don't denigrate, deride, or belittle the person in need - just move along.

1 Like

Programming / Re: Learning Programming. (my Nairaland Journal) by naijasensei: 2:12pm On Jan 08, 2021
yusman14:
To my own beginner understanding, after defining the function,the function takes/accept input known as parameters..Text is the only arbitrary parameters in the function,others are optional parameters which also indicates that the function can have default argument apart from "text"(which the user have to always enter)..others will be printed at default because they are optional parameters...if you return and print,you have to enter at least an argument for "text" parameter because it is not fixed to any value..other parameters can get values from users too but it is not compulsory for the user to enter a value because it is fixed..
the most important thing you should know is that OPTIONAL PARAMETERS COMES AFTER REQUIRED PARAMETERS.."TEXT" IS A REQUIRED PARAMETER HERE ..
I hope you understand...
This program will definitely return a dictionary if you print it .

Excellent explanation. cool

@syluck, I hope you have read this. The screenshot you posted is simply referring to optional parameters (which always have a default value, and can be omitted), and compulsory parameters - which must always be provided. In the screenshot, the 'text' parameter is the only compulsory parameter, while the others are optional.

P.S. What's with returning a dictionary though? I suspect you are probably mixing somethings up.
Programming / Re: Help Me Please. by naijasensei: 12:11pm On Jan 07, 2021
martius101:
good morning everyone,I have started learning programming from my phone but it's kinda hard for me and I don't have any money to get a laptop...but I still want to learn it at all cost.... please what interpreter should I use on my Android phone...i.e....an interpreter like Django..so that I can be able to see the output....thanks

I believe what you need is more of an IDE made for mobile. For example, there are Android based Python IDEs like Pydroid3 and QPython.
However if you really want compilers and interpreters, you should consider installing a terminal emulator like termux.

1 Like

Programming / Re: I Want To Learn Programming. Which Language Should I Start With? by naijasensei: 12:01pm On Jan 07, 2021
seunny4lif:
https://student.computing.dcu.ie/~ca106-133/index.html
Must of everything was done by me
Our 100L first semester project

Nice, clean, responsive design.
Programming / Re: Learning Programming. (my Nairaland Journal) by naijasensei: 9:01am On Jan 05, 2021
syluck:


Thanks.
Bro can u please in brief explain what' "Text file" in python is all about. I'm lost in that topic

Text files are simple files which lack the special formatting available in files produced by word processing software. As text files are popular and ubiquitous, it is only natural that every programming language has a way to access and modify text files. Other popular (universal) formats you should be interested in are JSON, XML, and CSV.
In python when you open a file, you create a resource object (which points to the file), with that resource you can now decide on the mode you want to open the file in (read only, write only, append, read/write, etc). From here you can then get the contents of the file, or even insert content into the file.
It is a broad topic, so I can't cover everything here.

2 Likes

Programming / Re: Learning Programming. (my Nairaland Journal) by naijasensei: 8:28am On Jan 04, 2021
syluck:

While loops can be so confusing

Yes, while loops are not as straightforward as for loops; but there are many instances where you have no choice but to use a while loop.
The main thing to remember about while loops is that you have a condition that must be monitored, and the condition must be evaluated at the end of each iteration through the loop in other to prevent an infinite loop.

while <condition>:
<statements>
<update condition>

1 Like

Programming / Re: Learning Programming. (my Nairaland Journal) by naijasensei: 4:49pm On Jan 03, 2021
syluck:
Okay I've tried running this code to my best of understanding. But I'm not getting what I need in the question.
I've successfully been able to code the question 1, going to question 2, it's just giving me an empty list.

Cc:
Naijasensei
Karleb
Semtu

Hi, peruse the code in the attached screenshot.

Programming / Re: Learning Programming. (my Nairaland Journal) by naijasensei: 2:39pm On Dec 20, 2020
KingAbdulazeez:
bosses in the house
I want to put the float input in the input function in the print function .
for example I input 60, I want the print function to update the value.

Programming / 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

Programming / 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

Programming / Re: A Thread For Tutorial On Python Programming by naijasensei: 5:00pm On Dec 12, 2020
onecoder:

And this is cleaner

matrix = [
[1,2,3],
[4,5,6],
[7,8,9]
]

for i, items in enumerate(matrix):
if i ==2:
print(matrix[i])


if you want to print every item of the 3x3 matrix, do this

for i, items in enumerate(matrix):
for i, value in enumerate(items):
print(items[i])

@Excallibur

Much cleaner, thanks.

1 Like

Programming / Re: Joining Two Tables In Php by naijasensei: 12:34pm On Dec 07, 2020
walterjnr:
Please I need help.
This image will explain everything. Thanks

First off, this isn't PHP - it is SQL, most likely MYSQL. Secondly, what are you doing? Thirdly, the second table is exactly the same as the first table, save for one column. Finally, aren't the columns in the proposed third table the same as those in the first table?
If you want my candid opinion, that database schema needs to be redesigned ASAP. It would be more efficient to have only a "tbltransaction" table and drop the "tbltransactionbank" table. Better still, you can keep the "tbltransaction" table while changing the transaction_type to type_id (or transaction_type_id) which will link to a transaction_type table. As a developer, always remember you have finite resources; don't waste computing resources on inefficient tasks.

1 Like

Programming / Re: NL API ? by naijasensei: 6:16pm On Dec 04, 2020
pcguru1:


Yeah that's the concept , I know there is no NL API, but I think someone wrote an API that used a scraper to fetch contents, but I want the bot to login and scrape all my contents and also make HTTP Post to modify all my content to something else. I feel one day our contents will be used against us, in this liberal world. so it will be good to be able to clear things pro-grammatically on demand.

Wow, I couldn't agree more with your motivation.
Programming / Re: NL API ? by naijasensei: 5:25pm On Dec 04, 2020
pcguru1:
Hi all, my favourite people on NL , I was curious about something, Someone once did something with Nairaland, they created an API around it, I am curious about the logging in, because I am experimenting with something I am not sure is possible, The goal is to see how one can scrape NL in order to modify all posts in a Scheduled manner.

An API? An official API? I believe the posting stuff can either be done with bots, or some some of job scheduler working on queued jobs.
Gaming / Re: I Want To Buy A PS VITA by naijasensei: 9:32am On Dec 03, 2020
pcguru1:


You are very very wrong, to emulate any platform you need 2 times the power, a PC can play games way more visually appealing than PS2 but the PS2 instruction sets are complex, and how pcsx2 built their project made it hard to re-write it. Because you are interpreting every ps2 instructions but the Emotion Engine and the GPU calls to match the CPU, and that often leads to bug. If you do interpreter even emulating a simple console will be very slow as it needs to fetch and decode each instruction. The reason Android games are faster is because Android games are built on C++ and your phones e.g have special instructions to add performance. Native code will always be faster compared to dynamic recompilation. PS3 emulator runs faster than PS2 emulator because the PS3 dev has very good knowledge of the system and prob some machine code knowledge to optimize. Just like the Dolphin emulator too. So it's because how the computation of the code is done and not the hardware. That's a common flaw most people fail to understand. The shit is hard, its genius to accomplish such sef

Most of the PS2 games even require patches for PCSX2 to run fast so.......

Many people will never understand what you typed up there. Emulating hardware can be tedious, the PS2 is notorious because Sony included so many esoteric things like the "Emotion engine" and some other things which an emulator has to fully emulate before you can even dream of playing games. The PS3 and Xbox360 consoles moved much closer to the x86 architecture used in PCs; this is why both the PS3 and Xbox360 emulators were developed in a shorter time compared to the PS2 emulator. The terrible performance of PS2 emulators on Android compared to Dolphin - an excellent Gamecube/Wii emulator - is a testament to how difficult PS2 emulation is, despite the fact that the Gamecube is slightly more powerful than the PS2. Also, as you alluded to, CPU power is more important in emulation than GPU power.
Gaming / Re: I Want To Buy A PS VITA by naijasensei: 9:03am On Dec 03, 2020
Ournolly:

Simple answer - it can't.
Just recently purchased redmi note 9 Pro that runs on sd 720g. Working flawless but the pes for android is overrated. Miles below ps4 version.

I agree with you that PES2021 Mobile is highly overrated. I installed it recently after uninstalling it some months ago, same frustrating game, same flaws, lazy developers, horrible online play, and no new modes. I promptly uninstalled the waste of space when it prompted me to install updates, good riddance to bad rubbish.

3 Likes 2 Shares

Gaming / Re: I Want To Buy A PS VITA by naijasensei: 8:56am On Dec 03, 2020
UnBanEbenezer:
hi bro I'm using a techno droipad 10D, it's a 2gb ram and 7000 mah battery with android version 7
I just came across this pes 2021 on playstore and it's 1.6Gb so I wanted asking if you got any idea if my phone would be able to play it cos I don't want to waste 1.6gb like that.
Screenshot below
cc Pcguru1

As pcguru1 rightly said, your tablet is using an outdated SoC - the Mediatek MT8735B. This SoC has a severely under powered (and under clocked) CPU with quad-core cortex A53 cores matched with an equally disappointing Mali T720 GPU. This SoC was released more than 6 years ago.
Back to your question; it might run the game (and this is a big if), but it is guaranteed to be a frustrating experience.
Programming / Re: Good News For Those That Want To Learn Python by naijasensei: 5:01pm On Dec 02, 2020
Karleb:
Whenever people recommend python because it can do all things, I always get surprised.

Even if python can approach all problems, it isn't fit for all problems.

If you want to go into mobile or desktop app development, python obviously isn't the best solution.


Very true.
Programming / Re: Good News For Those That Want To Learn Python by naijasensei: 12:25pm On Dec 02, 2020
Juliusmomoh:

Sorry for distubing u .,
Phython and java, which one strong pass when it comes to mobile app creating ? ...
My brother is currently learning JAVA and he kept covincing to learn dat language.
But i don't like it.
I love phython instead

Apologies if I sound harsh.

Be careful with your emotions. Both Python and Java are general purpose programming languages, however, every programming language has its speciality.
Python is best suited for Machine learning, AI, Data Science, and automation. These are not the only things Python can be used for, but these areas are where Python excels.
Java is mainly used for Android app development, and enterprise apps development.

Python has an easier learning curve than Java, true. Nonetheless, a programmer must always use the best tools available for the job. Python (with Kivy) can be used to develop mobile apps, but you will definitely run into problems down the road. The technology is not mature, is not widely adopted, and is certainly not widely supported. You will be entering a niche environment with a very limited community.

If I want to drive a nail into a surface, I will use a hammer. If I want to loosen or tighten screws, I will use a screwdriver. Always try to use the tools that are best suited for a particular job. The moment you start viewing every problem as a nail, then the only solution will always be a hammer.

Java/Kotlin are miles and away better for Android app development compared to Python. Similarly, Python is a better choice than Java for Machine learning. Recommended alternatives to Java/Kotlin for mobile app development are; React Native, Flutter, and Ionic.

The opinions expressed are my personal opinions, thanks.

1 Like

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (of 19 pages)

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