-
Notifications
You must be signed in to change notification settings - Fork 87.3k
Create Datastructures_assesment #83
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
base: master
Are you sure you want to change the base?
Conversation
|
||
Write a brief description of all the following Object Types and Data Structures we've learned about: | ||
|
||
Numbers: Both Integer and floting point number are saved as number in python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n = 10
print(n)
print(type(n))
out: 10
<class 'int'>
n = 10.2
print(10)
print(type(n))
out: 10.2
<class 'float'>
|
||
Numbers: Both Integer and floting point number are saved as number in python | ||
|
||
Strings: It can be assigned using single or double quotes. there are ordered sequence of characters that can be retrived by index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str = "string"
print(str)
print(str[1:])
print(type(str))
out: string
tring
<class 'str'>
|
||
Strings: It can be assigned using single or double quotes. there are ordered sequence of characters that can be retrived by index | ||
|
||
Lists:It is ordered sequence of objects that can be integer, float, string ,list or dictionary. they are mutable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list = [1,1.2,"str"]
list1 = [5,3,4]
print(list)
print(list[2])
print(list1)
list1.sort()
print(list1)
print(type(list))
out: [1, 1.2, 'str']
str
[5, 3, 4]
[3, 4, 5]
<class 'list'>
|
||
Lists:It is ordered sequence of objects that can be integer, float, string ,list or dictionary. they are mutable | ||
|
||
Tuples: They are same as List but start with () and are not mutable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tup = (1,1,2,"string")
print(tup)
print(type(tup))
out: (1, 1, 2, 'string')
<class 'tuple'>
|
||
Tuples: They are same as List but start with () and are not mutable | ||
|
||
Dictionaries:The hold key value pairs and any value can be retrieved using the key and they are represented with {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dict = {"word1":"a","word2":"b","word3":3}
print(dict)
print(dict["word2"])
print(type(dict))
out: {'word1': 'a', 'word2': 'b', 'word3': 3}
b
<class 'dict'>
This is why, by default, GitHub should have notifications set to off unless the user subscribes to updates: getting spammed emails at 5AM eastern on a Sunday just because I have access to the repository. Also, the emails github sends makes the user log into the site to update notifications rather than have a hyperlink in the email that redirects directly to the unsubscribe action. Such a joy to be dealing with these things before the sun comes up on a Sunday. Onward. https://help.github.com/en/articles/subscribing-to-and-unsubscribing-from-notifications ^ If you are tired of these spam emails. On a positive note: fantastic course professor. Keep the content coming. My only gripe is these notifications which I just remedied following the link above. |
Dictionaries:The hold key value pairs and any value can be retrieved using the key and they are represented with {} | ||
|
||
Numbers | ||
Write an equation that uses multiplication, division, an exponent, addition, and subtraction that is equal to 100.25. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print((10*10/2)**2+0.25-2400)
out: 100.25
|
||
Answer these 3 questions without typing code. Then type code to check your answer. | ||
|
||
What is the value of the expression 4 * (6 + 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
44
|
||
What is the value of the expression 4 * (6 + 5) | ||
|
||
What is the value of the expression 4 * 6 + 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
29
What is the value of the expression 4 * 6 + 5 | ||
|
||
What is the value of the expression 4 + 6 * 5 | ||
In [ ]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(4+5*6)
out: 34
What is the value of the expression 4 + 6 * 5 | ||
In [ ]: | ||
|
||
What is the type of the result of the expression 3 + 1.5 + 4? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(3 + 1.5 + 4)
print(type(3 + 1.5 + 4))
out: 8.5
<class 'float'>
s = 'hello' | ||
# Print out 'e' using indexing | ||
Reverse the string 'hello' using slicing: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s = "hello"
print(s[1])
print(s[::-1])
out: e
olleh
# Print out the 'o' | ||
|
||
# Method 1: | ||
In [ ]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s = "hello"
print(s[4])
out: o
|
||
# Method 1: | ||
In [ ]: | ||
# Method 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s = "hello"
print(s[-1])
out: o
|
||
In [ ]: | ||
# Method 1: | ||
In [ ]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list = [0,0,0]
print(list)
out: [0,0,0]
|
||
In [ ]: | ||
# Answer before running cell | ||
2 > 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False
In [ ]: | ||
# Answer before running cell | ||
2 > 3 | ||
In [ ]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(2>3)
out: False
2 > 3 | ||
In [ ]: | ||
# Answer before running cell | ||
3 <= 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False
In [ ]: | ||
# Answer before running cell | ||
3 <= 2 | ||
In [ ]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(3<=2)
out: False
3 <= 2 | ||
In [ ]: | ||
# Answer before running cell | ||
3 == 2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False
In [ ]: | ||
# Answer before running cell | ||
3 == 2.0 | ||
In [ ]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(3==2.0)
out: False
3 == 2.0 | ||
In [ ]: | ||
# Answer before running cell | ||
3.0 == 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True
3.0 == 3 | ||
In [ ]: | ||
# Answer before running cell | ||
4**0.5 != 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(4**2)
out: 2
print(2==2)
out: True
# Answer before running cell | ||
3.0 == 3 | ||
In [ ]: | ||
# Answer before running cell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True
l_two = [1,2,{'k1':4}] | ||
|
||
# True or False? | ||
l_one[2][0] >= l_two[2]['k1'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l_one = [1,2,[3,4]]
l_two = [1,2,{'k1':4}]
print(l_one[2][0] > l_two[2]["k1"])
out: False
|
||
In [ ]: | ||
d = {'simple_key':'hello'} | ||
# Grab 'hello' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d = {'simple_key':'hello'}
print(d["simple_key"])
out: hello
|
||
|
||
Tuples | ||
What is the major difference between tuples and lists? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tuples are imutable
list = [1,2,3]
tuples = (1.2.3)
What is the major difference between tuples and lists? | ||
|
||
|
||
How do you create a tuple? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tup = (1,2,3)
print(tup)
print(type(tup))
out: (1,2,3)
<class 'tuple'>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taking the course in Udemy - Complete Python Bootcamp: Go from zero to hero in Python 3 ([email protected])
first review, I found dificulties in how to find a square root of a number, reassign values in lists, Dictionaries and Sets.
this is my first review.
I'll check my faults and review lists, dictionaries ans Sets to complete my datastructure_assesment
I would love some feedback if it's possible.
thank you so much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to get feedback over my comments and issues, if there's any
thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... I've just realized that this is not mine... lol sorry bro. I'm new... I was exited with the asignment and I've open this file and writed.. if you're new also, at the moment, i use visual studio code and download the plug ins to python. you can test the output also... hope it helps. maybe we can help eachother in the future ;)
Please let me know how to write code and commit