This blog will feature free tutorials for Java and Python. These tutorials are for beginners to create their first program with these programming languages. Python and Java are good languages for anyone to learn.
Disclosure: This page contains affiliate links. If you choose to make a purchase after clicking a link, I may receive a commission at no additional cost to you. Thank you for your support!
This is a Python 3 tutorial for creating a counting program, and in order to get started I always start with a comment about what the program should entail. By using the # key, you can then create comments in Python.
# this is a simple while program that counts
number = int(input("Please provide a number between 1
and 100 that I can count to: "))
x = 1
if number >= x and number <= 100:
while
number >= x and number <= 100:
print(x)
x
= x+1
print("Thank
You! I enjoyed counting to the number", number)
else:
print("Sorry
I can't count to that!")
The code below is slightly similar to the code above but with slight differences.
# this is a simple while program that counts
number =
int(input("Please provide a number between 1 and 100 that I can count to:
\n "))
if number > 100 or number < 1:
print("sorry
I cant count to that!")
else:
x = 1
while
number >= x and number <= 100:
print(x)
x
= x+1
print("\nThank
You! I enjoyed counting to the number", number)
These are two slightly different codes for counting in
python. Remember when coding in python indentation is very important when copying
this code, you may want to ensure that the methods line up such as the if/else statements, and the loops such as while and for.
As always, check out my youtube channel for more java for beginners videos. If you have any recommendations on new content or if there are areas that could be more helpful for you in learning java, please leave a comment for me here or on my youtube channel. I will consider your recommendation and may make a video primarily related to any video requests you may have to help increase your knowledge of the matter.
Remember to subscribe to get new content as soon as it is available with my link below.
No comments:
Post a Comment