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

adding first commit to my python tutorial repo #15

Open
wants to merge 2 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
21 changes: 21 additions & 0 deletions python_sandbox_starter/lists.py
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
# A List is a collection which is ordered and changeable. Allows duplicate members.

# create list
numbers = [1, 2, 3, 4, 5, 6]
fruits = ['apples', 'oranges', 'grapes', 'pears']

#use constructor
numbers2 = list((9, 8, 7, 6, 5, 4, 3))

print(numbers, numbers2)
print(len(fruits))
print(fruits[2])

#append item to list
fruits.append('mangoes')

#insert into position of list
fruits.insert(0, 'strawberries')

# remove item from list
fruits.remove(fruits[2])
print(fruits)
13 changes: 13 additions & 0 deletions python_sandbox_starter/strings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Strings in python are surrounded by either single or double quotation marks. Let's look at string formatting and some string methods

name = 'Askhat'
age = 37

# Concatenate
print('Hello my name is '+ name + ' i`am ' + str(age) +'.')

# String Formatting

# arguments by position
print('my name is {name} i am {age}'.format(name = name, age = age))

#F-Strings
print(f'hello, my name is {name} and i am {age}')

# String Methods
s = 'hello, world!'
print(s.capitalize())
7 changes: 6 additions & 1 deletion python_sandbox_starter/tuples_sets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# A Tuple is a collection which is ordered and unchangeable. Allows duplicate members.

fruits = ('apples', 'oranges', 'grapes')
fruits2 = ('apples',)


print(fruits2, type(fruits2))
print(fruits[2])
fruits[0] = 'strawberry'
# A Set is a collection which is unordered and unindexed. No duplicate members.

11 changes: 11 additions & 0 deletions python_sandbox_starter/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@
- Must start with a letter or an underscore
- Can have numbers but can not start with one
"""
x=1
y = 2.1
name = "askhat"
is_cool = True

x, y, name, is_cool = (1, 2.5, 'askhat', True)
a = x + y

print(x, y, name, is_cool, a)

print(type(y))