Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,643 members, 7,809,418 topics. Date: Friday, 26 April 2024 at 09:14 AM

Here Is Why You Should First Learn Python As A Beginner In Programming - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Here Is Why You Should First Learn Python As A Beginner In Programming (2938 Views)

What Made You Pick Interest In Programming / Reasons To Choose Python As Your Next Web Project / First Thing First, Learn To Program! (2) (3) (4)

(1) (Reply) (Go Down)

Here Is Why You Should First Learn Python As A Beginner In Programming by Akin1212(m): 3:10pm On Sep 25, 2017
The following code in Python is 6 lines. In C++, Java, C#, PHP, Javascript the same program which is a multiplication table will take more than 20 lines.
The fact is Python is less wordy, simpler and straightforward than all other object-oriented languages.

1. size = int(input("Please enter table size: "wink)
2. for row in range(1, size + 1):
3. for column in range(1, size + 1):
4. product = row * column
5. print('{0:4}'.format(product), end= '')
6. print()

- The first line sets the variable 'size' and receives the input from the user as an integer, it then stores it in the variable size.
- The second line uses the 'for' keyword which is used for looping, it loops the sequences of numbers in the range 1 to any number value entered as 'size' + 1. +1 increments the value of the starting 1 to the value of the 'size' entered.
- The third line is the block of the 'for' loop, it is another 'for' loop nested into the first. It defines the column while the first defines the row.
- The fourth line simply calculates the products of the row vs the column using the variables created in the two 'for' loops.
- The fifth line prints the value of all the products basically but formatting it to have a basic shape as seen in the picture below.
- The sixth line Prints the whole multiplication table but the indention is backward to print backward. It is to make the shape looks good.

Python is the best
I write Java, Python, C++, C#, Javascript, Visual Basic, Objective c and c++ and recently GO.

2 Likes 1 Share

Re: Here Is Why You Should First Learn Python As A Beginner In Programming by Nobody: 3:16pm On Sep 25, 2017
Python is a general purpose language but saying it is the best ,no. i like python alot
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by Akin1212(m): 3:18pm On Sep 25, 2017
drunkcow:
Python is a general purpose language but saying it is the best ,no. i like python alot

Different strokes for different folks. I'm sure you'd have your own reasons for saying no, but for me, it's a big YES.
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by Nobody: 4:47pm On Sep 25, 2017
Akin1212:


Different strokes for different folks. I'm sure you'd have your own reasons for saying no, but for me, it's a big YES.
OkaY
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by kennyjam: 12:56am On Sep 26, 2017
Knocks, door opens,enters and gets a seat and sits down......thanks OP
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by sirusX(m): 7:52pm On Sep 26, 2017
Wow...that's really short
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by dabigjoe6(m): 2:04pm On Sep 27, 2017
sometimes number of lines of code does not qualify a programming language to be better, all programming languages have what they are best for implementing. I know someone who first learnt Python and found a little bit difficult at first to grasp c++. being simple doesn't make it the best.
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by Akin1212(m): 2:19pm On Sep 27, 2017
dabigjoe6:
sometimes number of lines of code does not qualify a programming language to be better, all programming languages have what they are best for implementing. I know someone who first learnt Python and found a little bit difficult at first to grasp c++. being simple doesn't make it the best.

You don't really get the idea. If you are a programmer then you will be acquainted with the saying 'the simpler, the better'. On the lines of code, the less the line of code of any program the faster the program, I'm surprised you don't know this.

The person you know who didn't grasp C++ after learning Python definitely has something wrong with him.

2 Likes

Re: Here Is Why You Should First Learn Python As A Beginner In Programming by dabigjoe6(m): 6:36pm On Sep 27, 2017
Akin1212:


You don't really get the idea. If you are a programmer then you will be acquainted with the saying 'the simpler, the better'. On the lines of code, the less the line of code of any program the faster the program, I'm surprised you don't know this.

The person you know who didn't grasp C++ after learning Python definitely has something wrong with him.
I write code in Java, c++ and Python it's not the length of code that matters when you are comparing two different languages, c++ is mostly used for AAA games because it is converted to machine language 0's and 1's it's a compiled language which makes it very fast. Python on the other hand is interpreted and can be used as a scripting language and web development (Django). In the real world hard ware intensive programs written in Python are usually prototypes they are later converted to other languages that are faster like C or c++.
Am not saying Python is not good or bad am just saying shorter lines of code compared to other languages does not make it the best.

3 Likes

Re: Here Is Why You Should First Learn Python As A Beginner In Programming by dabigjoe6(m): 6:50pm On Sep 27, 2017
Akin1212:


The person you know who didn't grasp C++ after learning Python definitely has something wrong with him.
I didn't say he didn't grasp c++, he found it a bit difficult to, because he was new to stuff like primitive data types which are absent in Python and the for loop was kind of different and also absence of the need for semi column in Python. Many beginners will find this overwhelming at first if they had been introduced to Python first.
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by Miscellaneous(m): 11:49pm On Sep 27, 2017
Akin1212:


You don't really get the idea. If you are a programmer then you will be acquainted with the saying 'the simpler, the better'. On the lines of code, the less the line of code of any program the faster the program, I'm surprised you don't know this.

The person you know who didn't grasp C++ after learning Python definitely has something wrong with him.

U are wrong. A shorter line of code is not always efficient
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by excanny: 11:53pm On Sep 27, 2017
Shorter codes doesnt mean your program will run faster or be more memory-efficient.

If you are an experienced programmer, you would know this truth.
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by Akin1212(m): 12:06am On Sep 28, 2017
Of course, fewer lines are not always better. But in my experience, fewer lines are often better than more lines in terms of readability and maintainability. There are exceptions, of course. And this is why I said to me Fewer lines makes a language better than the others. You people can have your opinions on this matter but this is mine and a lot of programmers agree on this.
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by escapefromusa(f): 1:56am On Sep 28, 2017
excanny:
Shorter codes doesnt mean your program will run faster or be more memory-efficient.

If you are an experienced programmer, you would know this truth.

Are you on crack.

A = range(0,20)

For i in A:
Print (i)

Vs

[i for I in range(0,20)]

Which is faster.

In the first case I have to take every i, then prolly append to a list.

In the second .. I just assign.

Are you serious.

It's like saying OOP is faster than functional.. not on your.life
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by HottestFire: 7:59am On Sep 28, 2017

Good point but one thing is, that a program has lesser lines of codes does not make it the essential to learn.
I started with C# before porting to python but the nitty gritty of C# makes python learning a cake.

I so much like the way python is used to manipulate data..

Re: Here Is Why You Should First Learn Python As A Beginner In Programming by excanny: 10:23am On Sep 28, 2017
escapefromusa:

Are you on crack.
A = range(0,20)
For i in A: Print (i)
Vs
[i for I in range(0,20)]
Which is faster.
In the first case I have to take every i, then prolly append to a list.
In the second .. I just assign.
Are you serious.
It's like saying OOP is faster than functional.. not on your.life
You could have just made your silly contribution without cursing yourself.
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by mexzony: 12:34pm On Sep 28, 2017
Akin1212:
Of course, fewer lines are not always better. But in my experience, fewer lines are often better than more lines in terms of readability and maintainability. There are exceptions, of course. And this is why I said to me Fewer lines makes a language better than the others. You people can have your opinions on this matter but this is mine and a lot of programmers agree on this.
if you are familiar with recursion and the Fibonacci numbers look at this code and see how intuitive and readable it is

static long Fib(int n)
{
if (n <= 2)
{
return 1;
}
return Fib(n - 1) + Fib(n - 2);
}

this is very intuitive and readable yet is one of the most inefficient forms of recursion and very slow and time consuming, memory consuming.
inshort try to find Fib(100) and you will stay with your PC for almost eternity.
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by escapefromusa(f): 5:20pm On Sep 28, 2017
excanny:


You could have just made your silly contribution without cursing yourself.

Ok.
Re: Here Is Why You Should First Learn Python As A Beginner In Programming by SUGARSON(m): 5:48pm On Feb 16, 2020
OP PLEASE EXPLAIN THE FIFTH LINE. I DON'T UNDERSTAND IT. I'M NEW TO PROGRAMMING.

(1) (Reply)

What Happened To Programming? / Buy All In One Brute/checker / Php Header() Function Error

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