Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,119 members, 7,814,925 topics. Date: Wednesday, 01 May 2024 at 11:42 PM

Coding Looks Cool. - Programming (3) - Nairaland

Nairaland Forum / Science/Technology / Programming / Coding Looks Cool. (18688 Views)

CODELAGOS: 337 Schools To Participate In Coding Competition / Learn Coding For Free, With Microverse, Pay The Tuition When You Start Earning. / Do We Have Coding Bootcamps In Nigeria? / Faster Way To Learn Web Development. (2) (3) (4)

(1) (2) (3) (4) (5) (Reply) (Go Down)

Re: Coding Looks Cool. by Daejoyoung: 11:24am On Nov 25, 2019
peterincredible:
going good I asked because i am taking the udemy course "Complete Python Bootcamp: Go from zero to hero in Python 3" by "Jose Portilla" and in the course after finishing the python 3 he then put another folder in it for python 2 am just thinking wont it be a waste pf time taking the python 2 as well i think i guess right will just ignore the python 2 part of the course"
and as for the tutorial it is going very good how your side na ?
python 2 would no longer be maintained from next year onwards.
Re: Coding Looks Cool. by peterincredible: 2:44pm On Nov 25, 2019
Grandlord:
I still dey work on projects my man.

The Jose Portilla course, does it have projects in it? I might want to look at it too. Did you pay for it?
no the course dont have projects oo just some few challenges after each section but u can just to look for projects on your own or mimic any small project wey u c for youtube and for the payment i didnt pay for it i just download thw whole course from freetutorials.us
Re: Coding Looks Cool. by Bossgem: 11:26pm On Nov 26, 2019
Hi guys! Can you please help me figure out how to print this hollow rectangle with for loops? I was able to do it with print () alone. But the instruction is to use for loop. I tried youtube but didn't get any good answers. Please help!

Re: Coding Looks Cool. by Maskyy(m): 11:27am On Nov 27, 2019
Bossgem:
Hi guys! Can you please help me figure out how to print this hollow rectangle with for loops? I was able to do it with print () alone. But the instruction is to use for loop. I tried youtube but didn't get any good answers. Please help!

With Python 3

def print_rectangle(n, m) :



for i in range(1, n+1 ) :

for j in range(1, m+1 ) :

if (i == 1 or i == n or

j == 1 or j == m ) :

print( "*", end="" )

else :

print( " ", end="" )



print()




# Driver program for above function

rows = 6

columns = 20
print_rectangle(rows, columns)
Re: Coding Looks Cool. by Bossgem: 2:17pm On Nov 27, 2019
Maskyy:


With Python 3

def print_rectangle(n, m) :



for i in range(1, n+1 ) :

for j in range(1, m+1 ) :

if (i == 1 or i == n or

j == 1 or j == m ) :

print( "*", end="" )

else :

print( " ", end="" )



print()




# Driver program for above function

rows = 6

columns = 20
print_rectangle(rows, columns)

Thank you! A friend of mine helped me figure it out yesterday. Thanks again.
Re: Coding Looks Cool. by Grandlord: 2:57pm On Nov 27, 2019
Bossgem:


Thank you! A friend of mine helped me figure it out yesterday. Thanks again.
I didn't see this earlier.


Number 10;

for row in range(4):
shape = " "
for column in range(20):
shape += "*"
print(shape)


Number 11;

for row in range(1, 5):
shape = ""
for column in range(1, 21):
if row == 1 or row == 4 or column == 1 or column == 20:
shape += "*"
else:
shape += " "
print(shape)





Number 12;

output = " "
for items in range(5):
shape += "*"
print (shape)


You can wrap it all up, in a function definition like that my bro did above, so the user can input whatever values they want to. I didn't want to do that because maybe you've not learnt functions yet?


I'd like to see your friend's solutions so I could know if there's another way I could write shorter and cleaner solutions. We're all learning. cool

Also, where did you get the exercises from please?
Re: Coding Looks Cool. by Grandlord: 3:55pm On Nov 27, 2019
Maskyy:


With Python 3

def print_rectangle(n, m) :



for i in range(1, n+1 ) :

for j in range(1, m+1 ) :

if (i == 1 or i == n or

j == 1 or j == m ) :

print( "*", end="" )

else :

print( " ", end="" )



print()




# Driver program for above function

rows = 6

columns = 20
print_rectangle(rows, columns)
Nice one bro. I didn't learn about this end= keyword though. I guess I'll have to go read it up. smiley
Re: Coding Looks Cool. by iCode2: 4:56pm On Nov 27, 2019
Grandlord:
I didn't see this earlier.


Number 10;

for row in range(4):
shape = " "
for column in range(20):
shape += "*"
print(shape)

Number 11;

for row in range(1, 5):
shape = ""
for column in range(1, 21):
if row == 1 or row == 4 or column == 1 or column == 20:
shape += "*"
else:
shape += " "
print(shape)




Number 12;

output = " "
for items in range(5):
shape += "*"
print (shape)

You can wrap it all up, in a function definition like that my bro did above, so the user can input whatever values they want to. I didn't want to do that because maybe you've not learnt functions yet?


I'd like to see your friend's solutions so I could know if there's another way I could write shorter and cleaner solutions. We're all learning. cool

Also, where did you get the exercises from please?
Seems programmers na. Chai make I rush go read small. grin

1 Like

Re: Coding Looks Cool. by Grandlord: 5:05pm On Nov 27, 2019
iCode2:
Seems programmers na. Chai make I rush go read small. grin
My man! grin grin
Re: Coding Looks Cool. by Kubernetes: 5:31pm On Nov 27, 2019
An advice to anyone learning.
The easiest place to learn a Lang faster is to go to the language documentation site.You hear first hand information and explaination from the horses mouth (those you created the program).You get to know all the data types and it relates bits and bytes,syntax,data structures,control statements, functions,OOP concepts etc from them.They even show you how to build some basic apps in that language.
e.g
Java doc site
Perl doc site
Python doc site
Infact after downloading the language,u will be directed to the learning documentation.
Also it's worth it,if you learn the basics of 32bits and 64 bits processors in relation to a transistor.Things like binary way of representing data.Also dig out how computer memory works in bits and bytes.

3 Likes 1 Share

Re: Coding Looks Cool. by Bossgem: 6:54pm On Nov 27, 2019
Grandlord:
I didn't see this earlier.


Number 10;

for row in range(4):
shape = " "
for column in range(20):
shape += "*"
print(shape)

Number 11;

for row in range(1, 5):
shape = ""
for column in range(1, 21):
if row == 1 or row == 4 or column == 1 or column == 20:
shape += "*"
else:
shape += " "
print(shape)




Number 12;

output = " "
for items in range(5):
shape += "*"
print (shape)

You can wrap it all up, in a function definition like that my bro did above, so the user can input whatever values they want to. I didn't want to do that because maybe you've not learnt functions yet?


I'd like to see your friend's solutions so I could know if there's another way I could write shorter and cleaner solutions. We're all learning. cool

Also, where did you get the exercises from please?

Ok. Thank you. I will go over your code. The thing is the chapter I'm reading is on for loop, so I'm expected to use only my knowledge of for loop to solve the exercises. I'm using a book, practical introduction to python. I have attached a screenshot of the book—that's what I'm using to study.

Re: Coding Looks Cool. by Bossgem: 6:57pm On Nov 27, 2019
Kubernetes:
An advice to anyone learning.
The easiest place to learn a Lang faster is to go to the language documentation site.You hear first hand information and explaination from the horses mouth (those you created the program).You get to know all the syntax,data structures,control statements, functions,OOP concepts etc from them.They even show you how to build some basic apps in that language.
e.g
Java doc site
Perl doc site
Python doc site
Infact after downloading the language,u will be directed to the learning documentation.

You're right about the documentation. One can actually download the entire documentation as a pdf file. I have the one for python for reference purposes

1 Like

Re: Coding Looks Cool. by Grandlord: 9:26pm On Nov 27, 2019
Bossgem:


Ok. Thank you. I will go over your code. The thing is the chapter I'm reading is on for loop, so I'm expected to use only my knowledge of for loop to solve the exercises. I'm using a book, practical introduction to python. I have attached a screenshot of the book—that's what I'm using to study.
Thanks. I've checked it out and there are lots of practice exercises on there to work on. smiley
Re: Coding Looks Cool. by Maskyy(m): 11:08pm On Nov 27, 2019
Bossgem:


You're right about the documentation. One can actually download the entire documentation as a pdf file. I have the one for python for reference purposes

Bennytechno1@gmail.com

Pls share
Re: Coding Looks Cool. by Bossgem: 7:30am On Nov 28, 2019
Maskyy:


Bennytechno1@gmail.com

Pls share

Sent.
Re: Coding Looks Cool. by Bossgem: 7:31am On Nov 28, 2019
Grandlord:
Thanks. I've checked it out and there are lots of practice exercises on there to work on. smiley

Yes, that's why I like the book.

1 Like

Re: Coding Looks Cool. by gbolly1151(m): 8:07am On Nov 28, 2019
For people who will be writing code you can use this tag

[Code] [/Code] (make C small letter) to make the code easy to read for programmers the output will be similar to below code


def greet('hello world):
return 'hello world'

print('hello world')

1 Like 1 Share

Re: Coding Looks Cool. by Grandlord: 9:11am On Nov 28, 2019
Bossgem:


Yes, that's why I like the book.
Problem is, it doesn't have an answers section where you can check, if you get stuck on an exercise.

Do you know of any question and answer kind of book?
Re: Coding Looks Cool. by Bossgem: 9:39am On Nov 28, 2019
Grandlord:
Problem is, it doesn't have an answers section where you can check, if you get stuck on an exercise.

Do you know of any question and answer kind of book?

Yes, it doesn't have answers. Kinda forces you to produce an answer or search for answers yourself. I don't have a book with exercises and answers.

2 Likes

Re: Coding Looks Cool. by Maskyy(m): 10:12am On Nov 28, 2019
Bossgem:


Sent.

Thanks
Re: Coding Looks Cool. by Grandlord: 12:31pm On Nov 28, 2019
Bossgem:


Yes, it doesn't have answers. Kinda forces you to produce an answer or search for answers yourself. I don't have a book with exercises and answers.
Okay. No wahala.
Re: Coding Looks Cool. by Maskyy(m): 12:25am On Nov 29, 2019
Who know about moat academy in lag. How standard are they.
Re: Coding Looks Cool. by OutOfTheAshes(m): 9:24am On Dec 02, 2019
Who can help me out. It's my school assignment.

Write a program that checks if a number is prime.

Thanks for your anticipated reply.
Re: Coding Looks Cool. by Maskyy(m): 1:14pm On Dec 02, 2019
OutOfTheAshes:
Who can help me out. It's my school assignment.

Write a program that checks if a number is prime.

Thanks for your anticipated reply.

1 Like

Re: Coding Looks Cool. by Maskyy(m): 1:20pm On Dec 02, 2019
OutOfTheAshes:
Who can help me out. It's my school assignment.

Write a program that checks if a number is prime.

Thanks for your anticipated reply.

function shPrime(num) {
var prime = num != 1;
for(var i=2; i<num; i++) {
if(num % i == 0) {
prime = false; break; } }
return prime; }

console.log(shPrime(3));
Re: Coding Looks Cool. by OutOfTheAshes(m): 1:21pm On Dec 02, 2019
[quote author=Maskyy post=84553968][/quote]

Thanks. What if it's a negative number? Will your code still run?
Re: Coding Looks Cool. by OutOfTheAshes(m): 1:24pm On Dec 02, 2019
Maskyy:


function shPrime(num) {
var prime = num != 1;
for(var i=2; i<num; i++) {
if(num % i == 0) {
prime = false; break; } }
return prime; }

console.log(shPrime(3));

If num is < 0, will the program still run?
Re: Coding Looks Cool. by OutOfTheAshes(m): 1:26pm On Dec 02, 2019
Maskyy:


function shPrime(num) {
var prime = num != 1;
for(var i=2; i<num; i++) {
if(num % i == 0) {
prime = false; break; } }
return prime; }

console.log(shPrime(3));

What if num = 10^9(1000000000), will the code still run?
Re: Coding Looks Cool. by Maskyy(m): 1:37pm On Dec 02, 2019
OutOfTheAshes:

What if num = 10^9(1000000000), will the code still run?
it will check run correctively.
Re: Coding Looks Cool. by OutOfTheAshes(m): 1:45pm On Dec 02, 2019
Maskyy:


it will check run correctively.

Will it run when num = -3

1 Like

Re: Coding Looks Cool. by Grandlord: 2:42pm On Dec 02, 2019
[quote author=Maskyy post=84553968][/quote] Bro which text editor is this please? VS code?
Re: Coding Looks Cool. by Maskyy(m): 4:32pm On Dec 02, 2019
Grandlord:
Bro which text editor is this please? VS code?

Yap

1 Like

(1) (2) (3) (4) (5) (Reply)

Programming Competition: Search Engine Task. Rewards up for grabs. / Is Python Really Worth The Buzz And Hype It's Getting ? / Where To Go If You Need Programmers Or Advertise Your Programming Skills

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