Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting Python #570

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions conditional statements,loops and logical operators
Original file line number Diff line number Diff line change
@@ -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")
95 changes: 95 additions & 0 deletions lists,data sets,tuples,ditionary
Original file line number Diff line number Diff line change
@@ -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())
50 changes: 20 additions & 30 deletions log.md
Original file line number Diff line number Diff line change
@@ -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))