From dc280cbfe78dd2eb181b3c95a390a4bd4b232073 Mon Sep 17 00:00:00 2001 From: Ian Arellano Date: Tue, 19 Oct 2021 11:16:16 -0500 Subject: [PATCH 1/5] adding test.py to practice python --- test.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test.py diff --git a/test.py b/test.py new file mode 100644 index 0000000..2b7e8fa --- /dev/null +++ b/test.py @@ -0,0 +1,56 @@ + +# BASICS +# a = 1 +# a = a + 1 +# b = a +# print(a) +# +# print("hello" * 3) +# +# print(a == 2) +# +# empty = None +# print(empty) +# +# # None() +# +# print(not a) +# +# print(1 == 1 and 2 == 2) + +# FUNCTIONS +# user_number = input("Enter a number: ") +# print(user_number) + +# print("Hello", "World") + +# IF ELSE AND ELIF + +its_raining = True +# if its_raining: +# print("It's raining!") + +# its_raining = False +# if its_raining: +# print("It's raining!") + +if its_raining: + print("It's raining!") +else: + print("It's not raining.") + +print("Hello!") +password = input("Enter the correct password: ") + +if password == "password": + print("Welcome, Sir.") +else: + print("Wrong password.") + +print("Hello!") +word = input("Enter something: ") + +if word == "hi": + print("Hi to you too!") +elif word == "hello": + print("Hello hello!") From c8f29d5504b4179fb4920a37ab97d1e62b866b40 Mon Sep 17 00:00:00 2001 From: Ian Arellano Date: Tue, 19 Oct 2021 16:38:03 -0500 Subject: [PATCH 2/5] finished exercises in if.md --- test.py | 67 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/test.py b/test.py index 2b7e8fa..e7f314e 100644 --- a/test.py +++ b/test.py @@ -26,7 +26,7 @@ # IF ELSE AND ELIF -its_raining = True +# its_raining = True # if its_raining: # print("It's raining!") @@ -34,23 +34,54 @@ # if its_raining: # print("It's raining!") -if its_raining: - print("It's raining!") -else: - print("It's not raining.") - -print("Hello!") -password = input("Enter the correct password: ") +# if its_raining: +# print("It's raining!") +# else: +# print("It's not raining.") +# +# print("Hello!") +# password = input("Enter the correct password: ") +# +# if password == "password": +# print("Welcome, Sir.") +# else: +# print("Wrong password.") +# +# print("Hello!") +# word = input("Enter something: ") +# +# if word == "hi": +# print("Hi to you too!") +# elif word == "hello": +# print("Hello hello!") -if password == "password": - print("Welcome, Sir.") -else: - print("Wrong password.") +# Exercise +# print("Hello!") +# something = input('Enter something: ') +# print('You entered:', something) +# +# print('Hello!') +# something = input("Enter something: ") +# if something == 'hello': +# print("Hello for you too!") +# +# elif something == 'hi': +# print('Hi there!') +# else: +# print("I don't know what,", something, "means.") -print("Hello!") -word = input("Enter something: ") +# user_input = input("Enter a word and I'll repeat it 1000 times: ") +# user_input += " " +# print(user_input * 1000) +# +# two_words = input("Enter two words: ") +# two_words += " " +# print(two_words * 1000) -if word == "hi": - print("Hi to you too!") -elif word == "hello": - print("Hello hello!") +password_checker = input("Please enter the correct password: ") +if password_checker == "Password": + print("Welcome!") +elif password_checker == "": + print("You didn't enter anything") +else: + print("Access denied") From 4e56564c2e429a1293bd8ef9fc32a0a35a5a4611 Mon Sep 17 00:00:00 2001 From: Ian Arellano Date: Wed, 20 Oct 2021 12:21:50 -0500 Subject: [PATCH 3/5] moved to practice folder and finished string-practice --- python-practice/string-practice.py | 48 ++++++++++++++++++++++++++++++ test.py => python-practice/test.py | 0 2 files changed, 48 insertions(+) create mode 100644 python-practice/string-practice.py rename test.py => python-practice/test.py (100%) diff --git a/python-practice/string-practice.py b/python-practice/string-practice.py new file mode 100644 index 0000000..42fe5e9 --- /dev/null +++ b/python-practice/string-practice.py @@ -0,0 +1,48 @@ +# my_string = "Hello World hello" +# +# print(my_string[-7:-2]) +# +# print(my_string[-1]) +# +# print(my_string.upper(), my_string.capitalize(), my_string.lower(), my_string.replace("o", "0", 2)) +# +# print(my_string.rindex('o')) +# +# print(my_string.upper()[3:].startswith('L')) + +# name = 'Cookie' +# print("Hello {}.".format(name)) +# print("Hello %s." % name) +# print(f"Hello {name}.") + +# print("C" in name) +# print("Hello" in name) +# print(len(name)) + +# print(str(42)) +# print(float("42.44")) +# print(int("42")) + +# Exercise + +# print("Hello!") +# word1 = input("Enter something: ") +# word2 = input("Enter another thing: ") +# word3 = input("Enter a third thing: ") +# word4 = input("And yet another thing: ") +# # Usable everywhere +# print("You entered %s, %s, %s, %s." % (word1, word2, word3, word4)) +# print("You entered {}, {}, {}, {}.".format(word1, word2, word3, word4)) +# # Only usable in Python 3.6 +# print(f"You entered {word1}, {word2}, {word3}, {word4}.") + +message = input("What do you want me to say? ") +message = message.upper() +print(message, "!!!") +print(message, "!!!") +print(message, "!!!") + +if message[::-1] == message: + print("It's a palindrome!") +else: + print("It's not a palindrome") diff --git a/test.py b/python-practice/test.py similarity index 100% rename from test.py rename to python-practice/test.py From 38a6ea848802f5866dff96edd92ab2903bc2b4c9 Mon Sep 17 00:00:00 2001 From: Ian Arellano Date: Wed, 20 Oct 2021 21:58:59 -0500 Subject: [PATCH 4/5] finished list-practice exercises --- python-practice/list-practice.py | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 python-practice/list-practice.py diff --git a/python-practice/list-practice.py b/python-practice/list-practice.py new file mode 100644 index 0000000..7116025 --- /dev/null +++ b/python-practice/list-practice.py @@ -0,0 +1,41 @@ +names = ['Bob', 'John', 'Steve', 'Dave'] +# print(len(names)) +# names += ['Robert'] +# print(names) +# print(names[:3]) +# print('Bob' in names) +# names.remove('Bob') +# names.remove('John') +# print(names) +# names.append('Don') +# print(names) +# names.extend(['Bob', 'John']) +# print(names) +# print(names) +# names[1] = 'Don' +# print(names) + +# numbers = [1, 2, 3, 4, 5] +# numbers_squared = [number ** 2 for number in numbers] +# print(numbers_squared) + +# numbers_two = numbers.copy() +# numbers_two.append(6) +# print(numbers, numbers_two) + +# Exercise +namelist = ['wub_wub', 'RubyPinch', 'go|dfish', 'Nitori'] +namelist.append('pb122') +if 'pb122' in namelist: + print("Now I know pb122!") + +# print("Hello!") +# name = input("Enter your name: ") +# print("Your name is %s." % name) + +namelist = ['wub_wub', 'RubyPinch', 'go|dfish', 'Nitori'] +namelist.extend('theelous3') +if input("Enter your name: ") in namelist: + print("I know you!") +else: + print("I don't know you.") From 7d4dd08767b3cf0a5728eb2a6a3795a7be1ed400 Mon Sep 17 00:00:00 2001 From: Ian Arellano Date: Wed, 20 Oct 2021 22:44:13 -0500 Subject: [PATCH 5/5] finished loop practice. still need more practice. loop is tough --- python-practice/loop-practice.py | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 python-practice/loop-practice.py diff --git a/python-practice/loop-practice.py b/python-practice/loop-practice.py new file mode 100644 index 0000000..2d5d595 --- /dev/null +++ b/python-practice/loop-practice.py @@ -0,0 +1,73 @@ +# its_raining = True +# while its_raining: +# print("It's raining!") +# answer = input("Or is it? (y=yes, n=no) ") +# if answer == 'y': +# print("Oh well...") +# elif answer == 'n': +# its_raining = False # end the while loop +# else: +# print("Enter y or n next time.") +# print("It's not raining anymore.") + +# raining = False +# while not raining: +# print("It's not raining.") +# if input("Is it raining? (y/n) ") == 'y': +# raining = True +# print("It's raining!") + +# stuff = ['hello', 'hi', 'how are you doing', 'im fine', 'how about you'] +# length_of_stuff = len(stuff) +# index = 0 +# while index < length_of_stuff: +# print(stuff[index]) +# index += 1 + +# for item in stuff: +# print(item) + +# for letter in "abcdefghijklmnop": +# print(letter) + +# for number in (1, 2, 3, 4, 5, 6): +# print(number) + +# Exercises +# things = [1, 2, 3, 4, 5] +# for thing in things: +# print(thing) +# +# before = [[1, 2], [3, 4], [5, 6]] +# after = [] +# for sublist in before: +# after.extend(sublist) +# print(after) +# +# string_numbers = ['1', '2', '3'] +# numbers = [] +# for string in string_numbers: +# numbers += [int(string)] +# result = 0 +# for n in numbers: +# result += n +# print("their sum is", result) + +# numbers = ['1', '2', '3'] +# actual_numbers = [] +# for number in numbers: +# actual_numbers.append(int(number)) +# print(actual_numbers) + +# row_count = int(input("Type the number of rows needed:")) +# for column_count in range(1, row_count+1): +# for number in range(1, column_count+1): +# print(number, end=" ") +# print() + +row_count = int(input("Type the number of rows needed:")) + +for line_number in range(1, row_count+1): + for number in range(line_number, row_count+1): + print(number, end=' ') + print()