PYTHON CODING AND C PROGRAMMING EXAMPLES: PROGRAMMING FOR BEGINNERS by KING J
Author:KING, J [KING, J]
Language: eng
Format: epub
Published: 2020-10-10T00:00:00+00:00
Create three lists of numbers, their squares and cubes
Example:
Input:
Start = 1
End = 10
Output:
numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
squares: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
cubes : [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
Logic
Three lists to declare.
Defining range, here we define beginning with 1 and ending with 10.
Run a loop with the range as range (start, end + 1) and count as loop counter.
Connect the count of the loop counter to the list named numbers, connect the square to the list called squares and add the cube to the list called cubes.
In the end, print out the lists.
PROGRAM
# declare lists
numbers = []
squares = []
cubes = []
# start and end numbers
start = 1
end = 10
# run a loop from start to end+1
for count in range (start, end+1) :
numbers.append (count)
squares.append (count**2)
cubes.append (count**3)
# print the lists
print "numbers: ",numbers
print "squares: ",squares
print "cubes : ",cubes
Output
numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
squares: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
cubes : [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
API Testing and Development with Postman by Dave Westerveld(3616)
Learning C# by Developing Games with Unity 2020 by Harrison Ferrone(2614)
Software Architecture for Busy Developers by Stéphane Eyskens(2320)
2021 Beginners Guide to Python Programming Language: A Crash Course to Mastering Python in One Hour by Elmer Gary & Elmer Gary(1884)
Machine Learning for Algorithmic Trading by Stefan Jansen(1628)
Hands-On ROS for Robotics Programming by Bernardo Ronquillo Japón(1572)
Delphi GUI Programming with FireMonkey by Andrea Magni(1457)
Game Development Projects with Unreal Engine by Hammad Fozi & Goncalo Marques & David Pereira & Devin Sherry(1402)
Cloud Native with Kubernetes by Alexander Raul(1374)
Datadog Cloud Monitoring Quick Start Guide by Thomas Kurian Theakanath(1346)
Software Architecture Patterns for Serverless Systems by John Gilbert(1338)
Practical Node-RED Programming by Taiji Hagino(1336)
Automate It with Zapier by Kelly Goss(1318)
Practical System Programming for Rust Developers by Prabhu Eshwarla(1312)
Delphi Programming Projects by William Duarte(1296)
Mastering React Test-Driven Development by Daniel Irvine(1289)
Developing Multi-Platform Apps with Visual Studio Code by Ovais Mehboob Ahmed Khan & Khusro Habib & Chris Dias(1253)
Ghidra Software Reverse Engineering for Beginners by A. P. David(1243)
Learn Spring for Android Application Development by S. M. Mohi Us Sunnat(1235)
