JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

python list V1 | JustPaste.app
22 days ago12 views
👨‍💻Programming

python list V1

when you want to create a variable, just type it's name and what it is:
name = "test" -> string
name = 1 -> int
name = 1.0 -> float
name = True -> boolean (important: the first letter needs to be capitalized (True/False))

you can also use
import random
to inport a few new functions, such as:
random(min, max)
that's it.

use round(varibale) to round it up/down

if you want to make an if statement, write it like this:
if THING:
[TAB]thing that should happen

examples:
if test > 2 and test < 8:
  print("hooray")
else:
  print("aw man")

if test > 5 || test < -5:
  print("bob challenge 4")

for loops:
if you want to make a for loop, write it like this:
for VARIABLE in range(0, LOOP_AMOUNT):
  print(VARIABLE)

if you type in this for example:
for i in range(0, 6):
  print(i)
it will print:
0
1
2
3
4
5

NOTE: it will stop before the the second number you inputted!

you can also let the user type in something

instead of using PRINT, use INPUT:

name = input("what's your name? ")

this will ask the user for their name and let them type it in. a simple program you could make using that would be:

name = input("hey! what is your name? ")
print("so your name is " + name + "?")

now, if you want the user to write a number, here is how you can check if it really is a number:
answer = 0
answer_input = input("hi, name me a random number: ")
  if anwer_input.isdigit():
    answer = int(answer_input)
  else:
    print("that isn't a number mate")
if you want to reuse code quickly, use a function:


import time

def colour(r=0, g=0, b=0):
    return f'\033[38;2;{r};{g};{b}m'
while True:
    party = input("wanna party? ")
    if party == "yes":
        while True:
            print(colour(255, 0, 0) + "party!")
            time.sleep(0.02)
            print(colour(255, 255, 0) + "party!")
            time.sleep(0.02)
            print(colour(0, 255, 0) + "party!")
            time.sleep(0.02)
            print(colour(0, 255, 255) + "party!")
            time.sleep(0.02)
            print(colour(0, 0, 255) + "party!")
            time.sleep(0.02)
            print(colour(255, 0, 255) + "party!")
            time.sleep(0.02)
    elif party == "no":
        print("aw man ):")
        exit()
    else:
        print("what..?")

← Back to timeline