Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f0cabfb
exercises from work
sabrina-dm Feb 17, 2026
7425bb3
ch08-challenge2
sabrina-dm Feb 17, 2026
0103a10
ch09-tuple
sabrina-dm Feb 17, 2026
5957f55
progressing tuples, lists
sabrina-dm Feb 23, 2026
dae6da4
added exercism exercises
sabrina-dm Mar 2, 2026
fcb1a25
progress with list methods
sabrina-dm Mar 2, 2026
8bea490
extend try expect with else and finally
sabrina-dm Mar 3, 2026
1115577
exercism bob and perfect_number
sabrina-dm Mar 3, 2026
e10c025
finish ch09
sabrina-dm Mar 4, 2026
14fd1c4
exercism triangle
sabrina-dm Mar 4, 2026
87484e0
ongoing pig-latin
sabrina-dm Mar 4, 2026
cc23fbf
exercism pig-latin without warnings
sabrina-dm Mar 5, 2026
15ba95f
concepts unlocked lists, string methods
sabrina-dm Mar 5, 2026
7131bf4
real-pyton progress nested lists and tuples
sabrina-dm Mar 6, 2026
f474146
exercism exercise work in progess
sabrina-dm Mar 6, 2026
0f19b84
added week-3 of open.hpi course
sabrina-dm Mar 9, 2026
3b78e4b
solved line-up.py from exercism
sabrina-dm Mar 9, 2026
6092262
ch09 up until and incl review exercise
sabrina-dm Mar 9, 2026
c650697
Test with slicing
sabrina-dm Mar 9, 2026
6edca9f
started challenge-list-of-lists
sabrina-dm Mar 10, 2026
79f8a57
working-not-really-pythonic solution
sabrina-dm Mar 11, 2026
abb1a87
solved isogram on exercism
sabrina-dm Mar 12, 2026
0a5184c
exercism isbn-verifier started
sabrina-dm Mar 12, 2026
9b2ea87
done rotational_cypher from exercism
sabrina-dm Mar 16, 2026
2904993
wax petric First try, working but with potential. redo later
sabrina-dm Mar 17, 2026
6e8a1c9
fooling around with finally
sabrina-dm Mar 17, 2026
8360741
renamed file
sabrina-dm Mar 18, 2026
8b9806b
removed because renamed
sabrina-dm Mar 18, 2026
e79a2fc
dictionary challenge capital city game
sabrina-dm Mar 18, 2026
ad4e3f3
progress week-3 hpi
sabrina-dm Mar 19, 2026
e62d300
solved exercism isbn-verifier
sabrina-dm Mar 20, 2026
1dbd7c5
exercism: solved learning exercise black jack
sabrina-dm Mar 20, 2026
0eab50f
exercism: solved darts
sabrina-dm Mar 20, 2026
50ae5c6
exercism learning string methods
sabrina-dm Mar 20, 2026
809efcf
exercism solved learning card_games
sabrina-dm Mar 20, 2026
36a70d3
exercism: solved resistor_color
sabrina-dm Mar 24, 2026
9a99c2c
Init vscodium
n8water Mar 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ch03-first-python-program/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This is a block comment
greeting = "Hello, World" # this is an inline comment
greeting

# Multiline may help a
# comment for clarity
74 changes: 74 additions & 0 deletions ch04-strings-and-string-methods/string-and-numbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# convert input (string) to numer

num = input("Enter a number to be doubled: ")
doubled_num = num * 2
print(doubled_num)



num = input("Enter a number to be doubled: ")
doubled_num = int(num) * 2
print(doubled_num)


# Review exercises

num_string = "5"
num_int = int(num_string)
print("String to int and multiplied is " + num_string)
print(num_int *2)


num_float = float(num_string)
print("Float from string multiplied by 3.5")
print(num_float * 3.5)


# string and integer object in print statment

text = "Hello"
num = 42
print(text + " " + str(num))

# 2 inputs are calculated and written

print("Please enter two numbers to multiply")
prompt = "Number 1: "
input1 = input(prompt)
prompt = "Number 2: "
input2 = input(prompt)
result = float(input1) * float(input2)
print(result)
print("The product of " + input1 + " and " + input2 + " is " + str(result) + ".")

# streamline your prints

name = "Zaphod"
heads = 2
arms = 3

# starting from python 3.6
print(name + " has " + str(heads) + " heads and " + str(arms) + " arms.")

# earlier versions use .format()
print("{} has {} heads and {} arms.".format(name, heads, arms))


# formatted strings
print(f"{name} has {heads} heads and {arms} arms.")

n = 3
m = 4
print(f"{n} times {m} is {n*m}")


# Review exercise

weight = 0.2
animal = "newt"

print( str(weight) + " kg is the weight of the " + animal)

print("{} kg is the weight of the {}".format(weight, animal))

print(f"{weight} kg is the weight of the {animal}")
14 changes: 14 additions & 0 deletions ch04-strings-and-string-methods/string-challenge-pick-apart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'''4.5. Challenge: Pick Apart Your User’s Input
4.5 Challenge: Pick Apart Your User’s
Input
Write a program named first_letter.py that prompts the user for in-
put with the string "Tell me your password:". The program should then
determine the first letter of the user’s input, convert that letter to up-
percase, and display it back.
For example, if the user input is "no", then the program should display
the following output
The first letter you entered was: N'''

prompt = "Tell me your password: "
user_input = input(prompt)
print("The first letter you entered was: " + user_input[:1].upper())
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Concatenation
string1 = "abra"
string2 = "cadabra"
magic_string = string1 + string2
print(magic_string)

first_name = "Arthur"
last_name = "Dent"
full_name = first_name + " " + last_name
print(full_name)

# Indexing
flavor = "fig pie"
print("Get character at index 1 of " + flavor )
print(flavor[1])

# get last character
print("Get last charakter")
print(flavor[-1])

# substring
flavor_substring = flavor[0:3]
print("Substring 0:3 of flavor")
print(flavor_substring)

# substring from 3 till end
flavor_end = flavor[3:]
print(flavor_end)

# no IndexError if I try to slice between boundaries outside the beginning or
# ending of a string
print("End of substring is outside the index range")
print(flavor[:14])

print("Start and End are outside the strings lenght")
print(flavor[13:15])

# strings are immutable meaning characters cannot be changed
# changes require new string assignments
word = "goal"
print("Initial word " + word)
word = "f" + word[1:]
print("Result after concatenation of f plus word[1:]")
print(word)

# exercise
test = "bazinga"
print(test[2:6])
56 changes: 56 additions & 0 deletions ch04-strings-and-string-methods/string-find.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# use .find() which returns the index of the start of the substring

phrase = "the surprise is in here somewhere"
to_find = "surprise"
print("Looking for " + to_find)
print(phrase.find("surprise"))
to_find = "eyjafjallajökull"

# find() returns -1 if not found
print("Now looking for " + to_find)
print(phrase.find("eyjafjallajökull"))

# find() is casesensitve and all characters must match
print(phrase.find("SURPRISE"))

# find() returns only the start indext of the first occurance
msg = "I put a string in your string"
print(msg)
print(msg.find("string"))

# numbers in string
text = "My number is 555-555-5555"
print(text)
# will cause TypeError
# print("Find 5")
#print(text.find(5))
print("Find '5'")
print(text.find("5"))


# replace
my_story = "I'm telling you the truth; nothing but the truth!"
print("Original: " + my_story)
print("replaced: " + my_story.replace("the truth", "lies"))
print("Call variable again to see it unaltered: " + my_story)
my_story = my_story.replace("the truth", "lies")
print("Finally: " + my_story)

# to replace various words
sample = "some of the stuff"
print("Go from: " + sample)
new_sample = sample.replace("some of", "all")
new_sample = new_sample.replace("stuff", "things")
print("To: " + new_sample)

# Review exercises
print("AAA".find("a"))

exercise2 = "Somebody said something to Samantha."
result2 = exercise2.replace("s", "x")
print(result2)

exercise3 = "Please give me a word: "
input_from_user = input(exercise3)
print(input_from_user.find("b"))

28 changes: 28 additions & 0 deletions ch04-strings-and-string-methods/string-interact-with-user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# get input

input()

prompt = "Hey, what's up? "
user_input = input(prompt)
print("You said: " + user_input)


# do something with the user input

response = input("What should I shout? ")
shouted_response = response.upper()
print("Well, if you insist..." + shouted_response)


# exercise
question = "What is your favourite colour? "
answer = input(question)
print(answer)

answer_lower = input(question).lower()
print(answer_lower)

print("Number of characters in your favorite colour is: ")
print(len(answer_lower))


133 changes: 133 additions & 0 deletions ch04-strings-and-string-methods/string-manipulate-with-methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# converting string case

name1 = "Jean-Luc Picard".lower()
print(name1)

name2 = "Jean-Luc Picard"
print(name2.lower())

print(name1.upper())

print("Length of the variable ")
print(len(name1))

'''
Remove whitespace three string methods
.rstrip()
.lstrip()
.strip()
'''

name1 = """Jean-Luc Picard """
print("Input with whitespace")
print(name1)
print(len(name1))

print("\nInput without whitespace")
print(name1.rstrip())
print(len(name1.rstrip()))




name1 = """ Jean-Luc Picard"""
print("Input with whitespace")
print(name1)
print(len(name1))

print("\nInput without whitespace")
print(name1.lstrip())
print(len(name1.lstrip()))


name1 = """ Jean-Luc Picard """
print("Input with whitespace")
print(name1)
print(len(name1))

print("\nInput without whitespace")
print(name1.strip())
print(len(name1.strip()))

'''
.startswith()
.endswith()
'''
print("\nstartswith and endswith")
starship = "Enterprise"
print("Does starship '" + starship + "' start with 'en'?")
print(starship.startswith("en"))

print("Does starship '" + starship + "' start with 'En'?")
print(starship.startswith("En"))

print("Does starship '" + starship + "' end with 'risE'?")
print(starship.endswith("risE"))


print("""\nUpper and lower do not change the string.
The return a copy""")


name = "Picard"
print(name.upper())
print(name)

print("To keep the change you need to assign it to the variable")
name = name.upper()
print("Result after name = name.upper()")
print(name)



# exercise

print("Animal".lower())
print("Badger".lower())
bee = "Honey Bee"
print(bee.lower())
print("Honey Badger".lower())

animal = "Animal"
badger = "Badger"
bee = "Honey Bee"
honey_badger = "Honey Badger"
print(animal.upper())
print(badger.upper())
print(bee.upper())
print(honey_badger.upper())


# exercise remove whitespace

string1 = " Filet Mignon"
string2 = "Brisket "
string3 = " Cheeseburger "

string1 = string1.lstrip()
string2 = string2.rstrip()
string3 = string3.strip()

print(string1)
print(string2)
print(string3)

startwith_string1 = "Becomes"
startwith_string2 = "becomes"
startwith_string3 = "BEAR"
startwith_string4 = " bEautiful"

print(startwith_string1.startswith("be"))
print(startwith_string2.startswith("be"))
print(startwith_string3.startswith("be"))
print(startwith_string4.startswith("be"))

startwith_string1 = startwith_string1.lower()
startwith_string3 = startwith_string3.lower()
startwith_string4 = startwith_string4.lstrip().lower()

print(startwith_string1.startswith("be"))
print(startwith_string2.startswith("be"))
print(startwith_string3.startswith("be"))
print(startwith_string4.startswith("be"))

31 changes: 31 additions & 0 deletions ch04-strings-and-string-methods/string_stuff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
string1 = 'Hello, World'
string2 = "1234"
string3 = "We're #1"
string4 = 'I said, "Put it over by the llama."'
text = "She said, \"What time is it?\""
long_string = "This multiline string is \
displayed on one line"
print(long_string)

paragraph = "This planet has—or rather had—a problem, which was \
this: most of the people living on it were unhappy for pretty much \
of the time. Many solutions were suggested for this problem, but \
most of these were largely concerned with the movements of small \
green pieces of paper, which is odd because on the whole it wasn't \
the small green pieces of paper that were unhappy."
print("\nLong paragraph one quote at begin and end\n")
print(paragraph)

# Triple quoted string preserve whitespace, including newlines
paragraph = """This planet has—or rather had—a problem, which was
this: most of the people living on it were unhappy for pretty much
of the time. Many solutions were suggested for this problem, but
most of these were largely concerned with the movements of small
green pieces of paper, which is odd because on the whole it wasn't
the small green pieces of paper that were unhappy."""
print("\nNew string called paragraph")
print(paragraph)

print("""An example of a
... string that spans across multiple lines
... and also preseves whitespace.""")
Loading