From c98917c7235cd51ea76ab3e7ab3ee37bb1ca84e7 Mon Sep 17 00:00:00 2001 From: Musheijaa <165941357+Musheijaa@users.noreply.github.com> Date: Mon, 22 Jul 2024 23:17:43 +0300 Subject: [PATCH 1/3] Starting Python Syntax and basic introduction to python --- log.md | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/log.md b/log.md index c7afe8f02ce..9544822f3cf 100755 --- a/log.md +++ b/log.md @@ -1,30 +1,20 @@ -# 100 Days Of Code - Log - -### Day 0: February 30, 2016 (Example 1) -##### (delete me or comment me out) - -**Today's Progress**: Fixed CSS, worked on canvas functionality for the app. - -**Thoughts:** I really struggled with CSS, but, overall, I feel like I am slowly getting better at it. Canvas is still new for me, but I managed to figure out some basic functionality. - -**Link to work:** [Calculator App](http://www.example.com) - -### Day 0: February 30, 2016 (Example 2) -##### (delete me or comment me out) - -**Today's Progress**: Fixed CSS, worked on canvas functionality for the app. - -**Thoughts**: I really struggled with CSS, but, overall, I feel like I am slowly getting better at it. Canvas is still new for me, but I managed to figure out some basic functionality. - -**Link(s) to work**: [Calculator App](http://www.example.com) - - -### Day 1: June 27, Monday - -**Today's Progress**: I've gone through many exercises on FreeCodeCamp. - -**Thoughts** I've recently started coding, and it's a great feeling when I finally solve an algorithm challenge after a lot of attempts and hours spent. - -**Link(s) to work** -1. [Find the Longest Word in a String](https://www.freecodecamp.com/challenges/find-the-longest-word-in-a-string) -2. [Title Case a Sentence](https://www.freecodecamp.com/challenges/title-case-a-sentence) +import math +name = print(input("What is your name?")) +#print(input("What is your name?")) +age = int(input("How old are you?:")) +height = float(input("How tall are you")) +print("Your "+str(age)+" years old") +print("Your "+str(height)+" tall") + +pi = 3.14 +x=23 +y=41 +z=52 +print(math.floor(pi)) +print(math.ceil(pi)) +print(math.sqrt(pi)) +print(abs(pi)) +print(pow(pi,2)) +print(round(pi)) +print(max(x,y,z)) +print(min(x,y,z)) From fc81805cd39dc5ff672a1ffc4b45861f729d97b1 Mon Sep 17 00:00:00 2001 From: Musheijaa <165941357+Musheijaa@users.noreply.github.com> Date: Tue, 23 Jul 2024 23:03:36 +0300 Subject: [PATCH 2/3] Create conditional statements,loops and logical operators project made alarm watch --- ...nal statements,loops and logical operators | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 conditional statements,loops and logical operators diff --git a/conditional statements,loops and logical operators b/conditional statements,loops and logical operators new file mode 100644 index 00000000000..83fc4071be7 --- /dev/null +++ b/conditional statements,loops and logical operators @@ -0,0 +1,49 @@ +import time +#if statement is a block of code to be executed if the ststement is true +""" +age = int(input("How old are you?:")) + +if age ==100: + print("You are a century old!") +elif age >=18: + print("You are an adult!") +elif age<0: + print("Your not born yet!") +else: + print("You are a child!") + #logical operators (and,or,not) = used to check if two or more conditional statements are true + + temp = int(input("What is the temperature outside?:")) + + if (temp >=0 and temp <=30): + print("the temperature is good today!") + print("go outside!") + elif(temp < 0 or temp >30): + print("the temperature is bad today!") +print("stay home!") + +#the not operator reverses the statement,if true to false and the viceverse + +#loops...a statement that will execute its block of code,as long a s its condition remains true + +while 1==1: + print("Help!! I'm stuck in a loop###") + +name = "" +while len(name) ==0: + name = input("Enter your name: ") + print("Hello "+name) +""" +#for loop = a satement that will execute its block of code a limited amount of times...while loop=unlimited ...for loop = limited + + +#for i in range(0,100+1,2): + # print(i) + +#for i in "Musheija": + # print(i) + +for seconds in range(20,0,-1): + print(seconds) + time.sleep(1) +print("Wake up") From db12bef13389e9bb052b72959231f54a7726622b Mon Sep 17 00:00:00 2001 From: Musheijaa <165941357+Musheijaa@users.noreply.github.com> Date: Wed, 24 Jul 2024 23:37:50 +0300 Subject: [PATCH 3/3] lists,data sets,tuples,ditionary lists,data sets,tuples,ditionary --- lists,data sets,tuples,ditionary | 95 ++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 lists,data sets,tuples,ditionary diff --git a/lists,data sets,tuples,ditionary b/lists,data sets,tuples,ditionary new file mode 100644 index 00000000000..8d3c102598f --- /dev/null +++ b/lists,data sets,tuples,ditionary @@ -0,0 +1,95 @@ +#nested loops = The inner loop will finish all of it's iterations before finishing one iteration of the "outer loop" +""" +rows = int(input("How many rows?: ")) +columns = int(input("How many columns?: ")) +symbol = input("Enter a symbol to use ") + +for i in range(rows): + for j in range(columns): + print(symbol,end="") + print() + #loop Control statements = change a loops execution from its normal sequence + + #break = used to terminate the loop entirely + #continue = skips to the next iteration of the loop + #pass = does nothing , acts as a placeholder + +while True: + name = input("Enter your name:") + if name != "": + break + + +phone_number = "123-456-7890 " + +for i in phone_number: + for i in phone_number: + if i =="-": + continue + print(i,end="") + +for i in range(1,21+1): + if i ==13: + pass + else: + print(i) + +#lists = used to store multiple items in a single variable + +food = ["pizza","hamburger","sumbi","chicken","beans"] +print(food) +#replacing a member of the list +#food[1]= "ovacado" +print(food[1]) +food.append("ice_cream")#adding at the end of the list +food.remove("hamburger")#removing an element from the list +food.pop()#removes the last element +food.insert(0,"cake")#places it in the index you want +food.sort()#arranges in alphabetical order + + +for x in food: + print(x) + +# 2D lists = a list of lists + +drinks = ["coffee","soda","tea"] +dinner =["pizza","chicken","pilau"] +dessert = ["cake","banana"] + +food =[drinks,dinner,dessert] +print(food[2][0]) + +#tuple = collection which is ordered and unchangeable used to group together related data + +student = ("musheija",30,"male") +print(student.count("male")) +print(student.index("male")) + + +#set = collection which is unordered,unindexed.No duplicate + +city = {"london","dubai","miami"} +cars ={"london","benz","ford"} + +#cars.add("volvo") +#cars.remove("london") +#city.clear() +#city.update(cars) +#max = city.union(cars) +#for i in cars: + #print(i) +print(cars.difference(city)) +print(cars.intersection(city)) +""" + +#dictionary = A changeable ,unordered collection of unique key:value pairs +#Fast because they use hashing,allow us to access a value quickly + +capitals = {"USA":"Washington DC","India":"Mumbai","uganda":"Kampala"} +print(capitals["USA"]) +print(capitals.get("uganda")) +print(capitals.get("china")) +print(capitals.keys()) +print(capitals.items()) +print(capitals.values())