python the hard way ex upto ex13

This commit is contained in:
samialazar 2020-05-19 16:28:33 +02:00
parent dab9fe5912
commit ed8222535a
7 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,16 @@
tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split\non a line."
backslash_cat = "I'm \\ a \\ cat."
fat_cat = """
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
"""
print(tabby_cat)
print(persian_cat)
print(backslash_cat)
print(fat_cat)

View File

@ -0,0 +1,8 @@
print("How old are you?", end=' ')
age = input(29)
print("How tall are you?", end=' ')
height = input(180)
print("How much do you weigh?", end=' ')
weight = input(78)
print(f"So, you're {age} old, {height} tall and {weight} heavy.")

View File

@ -0,0 +1,6 @@
age = input("How old are you? 27 years old ")
height = input("How tall are you? 1.80m ")
weight = input("How much do you weigh?78kg ")
print(f"So, you're {age} old, {height} tall and {weight} heavy.")

View File

@ -0,0 +1,10 @@
#Parameters, Unpacking, Variables
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)

View File

@ -0,0 +1,13 @@
formatter = "{} {} {} {}"
print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four"))
print(formatter.format(True, False, False, True))
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format(
"Try your",
"Own text here",
"Maybe a poem",
"Or a song about fear"
))

View File

@ -0,0 +1,15 @@
# Here's some new strange stuff, remember type it exactly.
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
print("Here are the days: ", days)
print("Here are the months: ", months)
print("""
There's something going on here.
With the three double-quotes.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
""")