Coder Social home page Coder Social logo

complete-python-3-bootcamp's People

Contributors

pierian-data avatar sprutner avatar tiventures avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

complete-python-3-bootcamp's Issues

More explanation of: with open(file.filename) as ...

Any chance of writing an explanation of the 'with' method/function (?) that you use in the video please? I got a little lost there. (Complete-Python-3-Bootcamp/00-Python Object and Data Structure Basics/08-Files.ipynb)

tep 2: Write a function that can take in a player input and assign their marker as 'X' or 'O'. Think about using while loops to continually ask until you get a correct answer.

#can i use this code??

def player_input():
value=input('make a choice:')
condition=True
while condition:
if value=='X':
print('you have choosen {}'.format(value))
return ('X','O')
break
elif value=='O':
print('you have choosen {}'.format(value))
return ('O','X')
break
else:
condition=False
while not condition:
value=input('please make a choice again between X or O:')
condition=True

When I type in the code it just shows: In[*].

When I first went on to Jupyter Notebook it worked fine, but after a few lessons of using it the code would not work at all and it would show: In[*]. No matter what code I put in it just wouldn't work. I tried restarting the Kernel, deleting other files, everything! I eventually went on to Jupyter lab but it did the exact same thing that Jupyter Notebook did. Can someone please help me out with this?

Downloading

I like to confirm if i can download the video to enable me watch the video training without using my data

can't write code

I am struggling tiwrite the code down it won't allow me to write anything

Error with 14_04

When attempting to open: 14-Advanced Python Objects and Data Structures/04-Advanced Dictionaries.ipynb I get an error that says: "Sorry, something went wrong. Reload?"

All other files have opened for me, thus far.

Milestone project - 1

Getting error list indices must be integrats or slices, not str
When trying to assign marker to board position

Goin in loop

below line of code is goin in loop...what mistake i am makingg
def player_input():

player1 = ''
player2 = ''

while (player1 != 'X' or player1 != 'O'):
    player1 = input('Please pick a marker X or O')
        
if player1 == 'X':
    player2 == 'O'
else :
    player2 == 'X'

Find_33 problem

Hi, everyone.
Can someone please explain to my what the expression "nums[i:i+2]" do in the find_33 problem.

The solution is like follows:
def has_33(nums):
for i in range(0, len(nums)-1):

    # nicer looking alternative in commented code
    #if nums[i] == 3 and nums[i+1] == 3:

    if nums[i:i+2] == [3,3]:
        return True  

return False

i need new line in this code

%%writefile mylife.txt
hello ord
hello cazy
hello weezy & zak
hello hemy & max
mylife=open('mylife.txt')
mylife.read()
mylife.seek(0)
mylife.read()
contents=mylife.seek(0)
mylife.readlines()
['hello ord \n', 'hello cazy\n', 'hello weezy & zak \n', 'hello hemy & max \n']
#i need above lines in new lines

Global example from slide

I had a question about the slide in the course that mentions the global function. The example was like this:

x = 50

def func(x):
print (f'X is {x}')
# local reassignment!
x = 200
print (f'I just locally changed x to {x}')

func(x)
--> X is 50
I just locally changed x to 200.

print(x)
--> 50

I totally get all of this. What happens next confuses me, when the global function is added.

x = 50

def func(x):
global x <------ shouldn't this be overwriting x as 200 everywhere?
print (f'X is {x}')
# local reassignment!
x = 200
print (f'I just locally changed x to {x}')

func(x)
--> X is 50 <------ so this should be 200? Why is it still 50?
I just locally changed x to 200.

print(x)
--> 200 <------- and this should also be 200?

Hope that's clear! Thank you so much!

python database program

perform aggregation,grouping,selfjoins & nested queries on database tables .
please give a code of this.

Kernels STILL Disconnecting...

I have been asking for assistance on my local kernel disconnecting for the past month. I am attempting to finish my certificate with the Udemy Python 3 course Zero to Hero. It seems when I run input functions ex:

def play_game():

  start_game = str(input("Ready..? Yes or No: ")).

A hourglass appears next to my Jupyter notebook. After I cannot run any code. The only solution I have found is to restart the kernel, but short thereafter if I run my input functions it occurs again. This is a very frustrating issue that has set me back a couple weeks from my anticipated end date for my Udemy course. I have no got any reliable feedback and would greatly appreciate some help with issue.

Thanks,

Thomas

Cant edit

Trying to do the functional practice exercise but it won't allow me to make any edits or changes in the coding?

program to find prime numbers

import math

def is_prime2(num):
'''
Better method of checking for primes.
'''
if num % 2 == 0 and num > 2:
return False
for i in range(3, int(math.sqrt(num)) + 1, 2):
if num % i == 0:
return False
return True

is the program correct, because for ever number it just returns true

Tic tac toe game

I get an error saying, "local variable 'position' referenced before assignment

'str' object has no attribute 'keys' while accessing Dictionary

##ini_dict = {'NYC': ['10.00', '5.00', '2.00'], 'SFO': ['12.00', '4.00', '2.00']} -- Initial dictionary
code to sum the value of each key in dictionary
result = {}
for d in ini_dict:
for k in d.keys(): --> Error str' object has no attribute 'keys'
result[k] = result.get(k, 0) + d[k]

Summer of '69 exercise faster solution

In the 03-Function Practice Exercises.ipynb notebook, Summer f '69 exercise, the instructor posted a long solution as an answer.

Wouldn't it be better to follow this approach instead?

def summer_69(arr):
    if (6 not in arr):
        print(0)
    else:
        print(sum((arr[0:arr.index(6)])+(arr[arr.index(9)+1:])))

Cant Chose 'o' in milestone project 1

from IPython.display import clear_output
def display_board(board):
clear_output()
print(board[7]+'|'+board[8]+'|'+board[9])
print(board[4]+'|'+board[5]+'|'+board[6])
print(board[1]+'|'+board[2]+'|'+board[3])

def player_input():
marker = ''

while not (marker=='X' or marker=='0'):
    marker = input('Player1 : Do you want to be X or O').upper()

if marker == 'X':
    return ('X','O')
else:
    if marker =='O':
        return ('O','X')

def place_marker(board,marker,position):

board[position]= marker

def win_check(board, mark):

   return ((board[7] == mark and board[8] == mark and board[9] == mark) or # across the top
(board[4] == mark and board[5] == mark and board[6] == mark) or # across the middle
(board[1] == mark and board[2] == mark and board[3] == mark) or # across the bottom
(board[7] == mark and board[4] == mark and board[1] == mark) or # down the middle
(board[8] == mark and board[5] == mark and board[2] == mark) or # down the middle
(board[9] == mark and board[6] == mark and board[3] == mark) or # down the right side
(board[7] == mark and board[5] == mark and board[3] == mark) or # diagonal
(board[9] == mark and board[5] == mark and board[1] == mark))

import random

def choose_first():

flip = random.randint(0,1)

if flip==0:
    return 'Player1'
else:
    return 'Player2'

def space_check(board,position):

return board[position]== ' '

def full_board_check(board):

for i in range(1,10):
    if space_check(board,i):
        return False

return True

def player_choice(board):

position = 0

while position not in range(1,10) or not space_check(board,position):
    position=int(input('choose a position: (1-9) '))
return position

def replay():

choice = input('Play Again? Enter Yes or No')

return choice== 'Yes'.lower()

print('Welcome To Tic Tac Toe!')

while True:

the_board= [' ']*10

player1_marker,player2_marker=player_input()

turn = choose_first()
print(turn+'will go first!')

play_game= input('Ready to play? y or n?')

if play_game== 'y':
    game_on = True
else:
    game_on = False
    
while game_on:
    
    if turn == 'Player 1':
        
        display_board(the_board)
        
        position = player_choice(the_board)
        
        place_marker(the_board,player1_marker,position)
        
        if win_check(the_board,player1_marker):
            display_board(the_board)
            print('Player 1 Has Won')
            game_on = False
        else:
            if full_board_check(the_board):
                display_board(the_board)
                print('Tie Game!!')
                break
            else:
                turn = 'Player 2'
            
                    
    else:
        display_board(the_board)
        
        position = player_choice(the_board)
        
        place_marker(the_board,player2_marker,position)
        
        if win_check(the_board,player2_marker):
            display_board(the_board)
            print('Player 2 Has Won')
            game_on = False
        else:
            if full_board_check(the_board):
                display_board(the_board)
                print('Tie Game!!')
                break
            else:
                turn = 'Player 1'
        
if not replay():
    break

cant chose o in milestone project 1 please help, point out my mistake

Dictionaries now retains insertion order in CPython 3.6+ and Python 3.7+

Hi Pierian-Data,

On this page:
https://github.com/Pierian-Data/Complete-Python-3-Bootcamp/blob/master/00-Python%20Object%20and%20Data%20Structure%20Basics/09-Objects%20and%20Data%20Structures%20Assessment%20Test.ipynb

You asked:
Can you sort a dictionary? Why or why not?

And in your keynote, you mentioned that the dictionary is unordered key-value pairs. I don't think that's true any more in CPython 3.6+ (as an implementation detail) and Python 3.7+ (as a language feature).

This is the mail found in python.org

https://mail.python.org/pipermail/python-dev/2017-December/151283.html

Though python still does not provide the sort method, we could still "sort" it as it retains insertion order.

sort_dict = lambda d: dict(sorted(d.items()))

03-Function Practice Exercises

The solution that has been provided for the question "Summer of 69" doesn't give the correct solution.

When it is tested with
summer_69([1, 3, 5]) => it is OK but
summer_69([6,1, 3, 5]) => it is not correct.

My solution is ;

def summer_69(arr):
total = 0
start = 0
end = 0
flag = False

for i in range(len(arr)):
    if arr[i] == 6:
        flag = True
        start = i

    if arr[i] == 9 and flag:
        end = i

    total += arr[i]

if start >= 0 and end >= 1:
    total = total - sum(arr[start:end+1])

return total

TypeError: 'str' object is not callable

Hi, I encountered this issue when I try to pass in a list object in a function inside another function. I have a game_on() function with all the main code. There I had a pre-defined value(hand) func to calculate hand value comparing to 21. but when I try to pass in player_hand, this error keeps pop out but when I wrote it eslewhere. it is fine. Please see attached screenshot:
Error 1

If I try to do the same at a new block, there will be no message as 'str' object is not callable. It would work as it should be.

Could you advise on the issue?

Thanks!

exercises palimdron

Write a Python function that checks whether a passed string is palindrome or not.

Note: A palindrome is word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run.

I have problem. When my string have more than 1 part "Nurses run", y take only first part "Nurses". I don't know why. Can someone help me?

def palindrom(string):
word = string.split(" ")
y = ""
for z in word:
y += z
if y.lower() == y.lower()[::-1]:
print(word)
print(y)
return f" True word = {y.lower()}, palindrom = {y.lower()[::-1]}"
else:
print(word)
print(y)
return f"False word = {y.lower()}, palindrom = {y.lower()[::-1]}"

**kwargs, return in list

Hi everyone
Can anyone help me to return a list when using **kwargs or *args
I have tryied following:
def myfunc(**kwargs):
I=list(kwargs)
for i in I:
if i %2==0:
return i

Please help me out:)

Error on File I/O

i get this error
%%UsageError: %%writefile is a cell magic, but the cell body is empty.
while i am writing a code of : %%writefile test.txt

Enlisting Function - Homework Q.5

Hello,

I was just wondering for the Functions and Methods homework assignment question 5 - multiply all the numbers in a list - are the square brackets used to turn 'numbers' into a list with an unknown number of variables?
e.g.

def multiply(numbers):
total = numbers[0] <----- I don't quite get this bit - why [0]?
for x in numbers:
total *=x
return total

Thanks so much for your help!

ipywidgets widgets not displaying

Hi,

For some reason, I can't get the widgets to display. Below is a screenshot I took that shows interact() not working. Is there a bug with ipywidgets? Thanks for your help!

no_slider

python 3.7.4 syntax error

####while running this code in python shell, getting invalid syntax in the second line of code
class line:
def__init__(self,coor1,coor2): ### invalid syntax ###
self.coor1=coor1
self.coor2=coor2
def distance (self):
x1,y1=self.coor1
x2,y2=self.coor2

                  return ((x2-x1)**2 + (y2-y1)**2)**0.5
        def slope (self);
                 x1,y1=self.coor1
                 x2,y2=self.coor2

    return (y2-y1)(x2-x1)

coor1=(3,2)
coor2=(8,10)

myline= line(coor1,coor2)

Download Test file

No download option is available for test .ipnyb or notebook file. How do you perform the test?

milestone2 :AttributeError: 'Deck' object has no attribute 'deck'

Cant understand why am I getting this error?
Thanks for your help.

class Deck:
def __init__self():
self.deck =[]
for i in shapes:
for j in rank:
self.deck.append(card(rank,shapes))

def __str__(self):
    return f'The CardDeck is {self.deck}'

def deal(self):
    random.shuffle(self.deck)

def deal(self):
    self.deck.pop()

test_deck = Deck()
print(test_deck)

trying to understand logic

this is level 2 problems from function exercise
Given a list of ints, return True if the array contains a 3 next to a 3 somewhere.
sol:
def has_33(nums):
for x in range(0,len(nums)-1):
if nums[x:x+2] == [3,3]:
return True
else:
return False

here, we want to find array contains 3 next to 3.
in slicing we need to put nums[x:x+1]
I think we need to check next position so we need to use x:x+1
but we are using x:x+2
please help me understanding this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.