Skip to content

Conversation

kavikempwodeyar
Copy link

Please let me know how to write code and commit


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
Copy link

@joefoe2000 joefoe2000 Sep 29, 2019

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

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
Copy link

@joefoe2000 joefoe2000 Sep 29, 2019

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

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 {}

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'>

@Mic-Sierra
Copy link

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.

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)

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

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 [ ]:

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?

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:

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 [ ]:

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:

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 [ ]:

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

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 [ ]:

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

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 [ ]:

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

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 [ ]:

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

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

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

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']

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'

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?

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?

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'>

Copy link

@joefoe2000 joefoe2000 left a 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

Copy link

@joefoe2000 joefoe2000 left a 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

Copy link

@joefoe2000 joefoe2000 left a 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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants