Skip to content

Instantly share code, notes, and snippets.

View santosadrian's full-sized avatar
💭
Buscándome la vida que la muerte viene sola.

Adrian Santos santosadrian

💭
Buscándome la vida que la muerte viene sola.
View GitHub Profile
@santosadrian
santosadrian / scratch_11.py
Created February 2, 2020 14:13
Example 11
print("How old are you?", end=' ')
age = input()
print("How tall are you?", end=' ')
height = input()
print("How much do you weight?", end=' ')
weight = input()
print(f"So, you are {age} old, {height} tall and {weight} heavy.")
@santosadrian
santosadrian / scratch_12.py
Created February 2, 2020 14:13
Example 12
age = input("How old are you? ")
height = input("How tall are you? ")
weight = input("How much do you weight? ")
print(f"So, you're {age} old, {height} tall and {weight} heavy.")
@santosadrian
santosadrian / scratch_13.py
Created February 2, 2020 14:36
Example 13
from sys import argv
# Read the WYSS section for how to run this
script, first, second, third = argv
print("The script is called:", script)
print("Your first variable is:", first)
print("Your second variable is:", second)
print("Your third variable is:", third)
@santosadrian
santosadrian / scratch_14.py
Created February 3, 2020 12:04
Example 14
from sys import argv
script, user_name = argv
prompt = "$>"
print(f"Hi {user_name}, I'm the {script} script")
print("I'd like to ask you a few questions.")
print(f"Do you like me {user_name}?")
likes = input(prompt)
@santosadrian
santosadrian / scratch_15.py
Created February 3, 2020 12:05
Example 15
from sys import argv# Imports module argv from library sys
script, filename = argv# get and set script and filename variables from user input
txt = open(filename)# set variable txt with a function
print(f"Here's your file {filename}") # This prints a sentence and a variable print(f"bla {variable"}
print(txt.read()) # this print a call to a variable that consist in a function
print("Type the filename again:") # print a string
@santosadrian
santosadrian / scratch_14.py
Created February 3, 2020 14:46
Example 14
from sys import argv
script, user_name = argv
prompt = "$>"
print(f"Hi {user_name}, I'm the {script} script")
print("I'd like to ask you a few questions.")
print(f"Do you like me {user_name}?")
likes = input(prompt)
@santosadrian
santosadrian / scratch_15.py
Created February 3, 2020 14:46
Example 15
from sys import argv# Imports module argv from library sys
script, filename = argv# get and set script and filename variables from user input
txt = open(filename)# set variable txt with a function
print(f"Here's your file {filename}")# This prints a sentence and a variable print(f"bla {variable"}
print(txt.read()) # this print a call to a function (read)
print("Type the filename again:")# print a string
@santosadrian
santosadrian / scratch_16.py
Created February 3, 2020 16:24
Example 16
from sys import argv
script, filename = argv
print(f"We're going to erase {filename}.")
print("If you don't want that hit CTRL-C {^C}.")
print("If you do not want that, hit RETURN.")
input("?")
@santosadrian
santosadrian / scratch_17.py
Created February 3, 2020 17:55
Example 17
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print(f"Copying from {from_file} to {to_file}")
# we could do these two on one line, how?
in_file = open(from_file)
in_data = in_file.read()
@santosadrian
santosadrian / scratch_18.py
Created February 4, 2020 08:09
Example 18
# this one is like your scripts with argv
def print_two(*args):
arg1, arg2 = args
print(f"arg1: {arg1}, arg2: {arg2}")
# ok, that *args is actually pointless, we can just do this shorter
def print_two_again(arg1, arg2):
print(f"arg1: {arg1}, arg2: {arg2}")
# this just takes one argument