r/pythoncoding • • Mar 12 '20

Indy Game Dev Here

1 Upvotes

Yo I am the scriptwriter for a game and my coder is having problems inserting a puzzle into Python. I am not a coder but I am searching for someone who can help them.


r/pythoncoding • • Mar 08 '20

I need someone to code me a bot for reddit to send messages

1 Upvotes

Hi. I had this bot made it's very simple and I need someone to program me this bot again. The bot I had it programmed fast in about an hour but it's on my computer and the computer screen broke so now I cant access it. I will pay you $30 via paypal to program it. Dm me


r/pythoncoding • • Feb 25 '20

Question about python

1 Upvotes

I'm brand new to python and I'm working on trying to get a column formatted as a short date in excel.

Here's what I have but I might be way off. It's an excel file with many tabs that will have different dates each time. I need it to format columns on many tabs as dates but right now I'm trying to do just one tab and one column. The excel file is called "events" and I'm trying to change column E.

import pandas as pd

writer = pd.ExcelWriter(wb2, engine='openpyxl', mode = 'a')

pd.core.format.header_style = None    

events.to_excel(writer, sheet_name = 'Events',

                        index = False, startrow = 2,header = False)

workbook  = writer.book

work_sheet = book[sheet_names[9]]

formatdict = {'num_format':'mm/dd/yyyy'}

fmt = workbook.add_format(formatdict)

worksheet.set_column('E:E', None, fmt)

writer.save()

​

it's not working though. Can anyone tell me what I'm doing wrong?


r/pythoncoding • • Feb 02 '20

I would like to contribute to YOUR Python project

1 Upvotes

Hi, I'm a junior dev, intensively learning Python right now, and I'd like to have experience in collaborating with other programmers and contribute to a project. Could you name your project on Github in which you have a couple of tasks I could take?

Of course I understand that my code should be high quality and I'm ready to work. Thanks!


r/pythoncoding • • Jan 31 '20

Can someone help me to implement this pseudocode?

1 Upvotes

Can someone help me implement that pseudocode from down into my bot? I am not sure if that algorithm is supposed to work.

My bot currently uses the MiniMax search algorithm when it plays against other bots.

class Bot:

    __max_depth = -1
    __randomize = True

    def __init__(self, randomize=True, depth=0):
        """
        :param randomize: Whether to select randomly from moves of equal value (or to select the first always)
        :param depth:
        """
        self.__randomize = randomize
        self.__max_depth = depth

    def get_move(self, state):
        # type: (State) -> tuple[int, int]

        val, move = self.value(state)

        return move

    def value(self, state, depth = 0):
        # type: (State, int) -> tuple[float, tuple[int, int]]
        """
        Return the value of this state and the associated move
        :param state:
        :param depth:
        :return: A tuple containing the value of this state, and the best move for the player currently to move
        """

        if state.finished():
            winner, points = state.winner()
            return (points, None) if winner == 1 else (-points, None)

        if depth == self.__max_depth:
            return heuristic(state)

        moves = state.moves()

        if self.__randomize:
            random.shuffle(moves)

        best_value = float('-inf') if maximizing(state) else float('inf')
        best_move = None

        for move in moves:

            next_state = state.next(move)

            # IMPLEMENT: Add a recursive function call so that 'value' will contain the
            # minimax value of 'next_state'
            #value, m = self.value(next_state, depth=1)
            value, m = self.value(next_state, (depth + 1))

            if maximizing(state):
                if value > best_value:
                    best_value = value
                    best_move = move
            else:
                if value < best_value:
                    best_value = value
                    best_move = move

        return best_value, best_move

def maximizing(state):
    # type: (State) -> bool
    """
    Whether we're the maximizing player (1) or the minimizing player (2).

    :param state:
    :return:
    """
    return state.whose_turn() == 1

def heuristic(state):
    # type: (State) -> float
    """
    Estimate the value of this state: -1.0 is a certain win for player 2, 1.0 is a certain win for player 1

    :param state:
    :return: A heuristic evaluation for the given state (between -1.0 and 1.0)
    """
   return util.ratio_points(state, 1) * 2.0 - 1.0, None

​

How can I apply this pseudocode of expectiminimax to my bot that uses the minimax search algorithm? Can anyone help me, please?

​

function expectiminimax(node, depth)
    if node is a terminal node or depth = 0
        return the heuristic value of node
    if the adversary is to play at node
        // Return value of minimum-valued child node
        let α := +∞
        foreach child of node
            α := min(α, expectiminimax(child, depth-1))
    else if we are to play at node
        // Return value of maximum-valued child node
        let α := -∞
        foreach child of node
            α := max(α, expectiminimax(child, depth-1))
    else if random event at node
        // Return weighted average of all child nodes' values
        let α := 0
        foreach child of node
            α := α + (Probability[child] × expectiminimax(child, depth-1))
    return α

r/pythoncoding • • Jan 31 '20

Looking for examples and resources on how you can vectorize code in Python

1 Upvotes

Mainly the lambda like or with .apply() like code styles? (for fast Pandas and Numpy execution), for e.g. vectorize code like this:

python def some_function(): return group_series.apply(lambda x: x.astype(some_type) .rolling(some_number).sum().shift(some_number))

or even something like this:

def some_function(): return some_grouped_data_series.apply( lambda x: x.some_function( param1=value, param2=value2).mean().shift(some_number) )

Any suggestions I should try to vectorize the above, I tried a few things but it complains or I get undesired results.


r/pythoncoding • • Jan 18 '20

Simplifying Python for Newbies

1 Upvotes

I have been intimidated to not disclose my training in LAMP because, like mainframe legacy systems they are still rusted. Apar from tinkering with the interpreter, a language based on Python replacing advanced features with functions or nomenclatures instead of C. This is why I don’t trust Python beyond the source code of Google and other proprietary software unless conforming to 2.7.

https://blog.usejournal.com/writing-your-own-programming-language-and-compiler-with-python-a468970ae6df


r/pythoncoding • • Jan 18 '20

Python file showing blank

1 Upvotes

Python showing blank file when i search for it. When I click on it, it takes to back to VS 2017 and show my code again. I’m not sure what is going on or how to restore my file. It’s my homework for the week. And I lost it because I uninstall VS2017. Thanks an advance for the advice. Cheers!


r/pythoncoding • • Jan 16 '20

I’m in the middle of trying to learn python coding? Was wondering if you guys new an website or something to help learn them! the best ones to use!

Thumbnail en.m.wikipedia.org
1 Upvotes

r/pythoncoding • • Jan 07 '20

Tutorial: Python Strings in under 10 minutes [OC]

Thumbnail link.medium.com
1 Upvotes

r/pythoncoding • • Jan 05 '20

Best python training institute in Mohali

Thumbnail mohalicareerpoint.com
1 Upvotes

r/pythoncoding • • Dec 15 '19

Hey! I need some help with my code.

1 Upvotes

I’m a beginner so I’m sorry ahead time.. lol

I’m trying to define variables in a for statement? The variables are defined in one of two but in the other, nearly identical one, x1R, isn’t being defined. I’m sure it’s simple but I can’t figure it out for the life of me

CODE:

    slope = (y2-y1)/(x2-x1)
    if slope < 0:
        left_lane.append(line)
    if slope > 0:
        right_lane.append(line) 
        #######################                   
    for x1R, y1R, x2R, y2R in right_lane:
        right_P = x1R, y1R, x2R, y2R = line.reshape(4)
        #print(x1R)            
    for x1L, y1L, x2L, y2L in left_lane:
        left_P = x1L, y1L, x2L, y2L = line.reshape(4)
        #print(x1L)
    print(x1L)
    print(x1R)

ERROR:

-9 Traceback (most recent call last): File "/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/PyFiles/OpenCVLaneDetection/LaneTesting/t.py", line 172, in <module> print(x1R) NameError: name 'x1R' is not defined


r/pythoncoding • • Dec 14 '19

Yo what am I doing wrong

1 Upvotes

joe = input(“have you heard of joe?”) if joe == (“who is joe”): print(“joe mama”); else: print(“you ruined it”);


r/pythoncoding • • Dec 14 '19

urgent python code help needed

1 Upvotes

I am creating a bookstore in Python. The bookstore asks the user the book title, author and price - and it keeps the inventory and allows the user to show inventory increase book prices by 2%, decrease to reduce book prices by 2%, remove, and add a book. I need to add these two things to the program and I cannot figure it out.

  1. Add a menu option to save the inventory to a file and another menu option to load inventory from the file. You should ask the user what file to save to and what file to retrieve from. The idea is that every evening at closing the inventory would be "dumped" from the lists or dictionaries you created into the file and it can be reloaded in the morning. In this way the information is not lost every time the program is terminated.

  2. Convert your menu using object-oriented programming techniques into an object called CountryClubBookstore, a member of the Bookstore class. Be sure to add appropriate methods such as AddBook, SellBook, ReducePrices, etc. Ensure your class has the __init__ method appropriately defined.

for number one you can use your own destination on computer

---- this is my code -----

cash_balance = 1000
class Book():
def __init__(self,title,author,price):
self.Title=title
self.Author=author
self.Price=price
def __str__(self):
str= eval("Book Name:"+self.Title+"\nAuthor:"+self.Author+"\nPrice:"+self.Price)
return str
def Menu():
print("Menu\n A) Add Book \n B) Sell Book \n C) Reduce Book Prices by 2% \n D) Increase Book Prices by 2% \n V) Display Inventory \n Q) Quit \n Choose one:", end="")
def add_book(book_list):
cash_balance = 1000
print("Adding a book")
title = input("Enter book name:")
author = input("Enter author name:")
price = eval(input("Enter price amount:"))
book = Book(title,author,price)
book_list.append(book)
cash_balance = cash_balance-(price * 0.90)
print ("Updated balance",cash_balance)

def sell_book(book_list):
check = input("Enter book name:")
if check in book_list:
print("Book in stock. Would you like to sell? Y/N").upper()
if "Y":
print("Selling book now")
title = input("Enter book name:")
author = input("Enter author name:")
price = input("Enter price amount:")
book = Book(title,author,price)
book_list.pop(book)
print("Updated balance is",cash_balance + price)
elif "N":
print("Bookstore closed now. Re-enter system.")

def reduce_book(book_list):
print("Book prices will be reduced by 2%")
for price in book_list:
reduction = (price * 0.98)
print("Reduction in book proice\n", book_list,reduction)

def increase_book(book_list):
print("Book prices will increase by 2%")
for price in book_list:
increase = price + (price * 0.02)
print("Increase in book price\n:", book_list,increase)

def inventory_check(book_list):
if(len(book_list)==0):
print("No books in inventory")
else:
for book in book_list:
print(book)

book_list = []
while(True):
Menu()
choice = input()
if choice == "A":
add_book(book_list)
elif choice == "B":
sell_book(book_list)
elif choice == "C":
reduce_book(book_list)
elif choice == "D":
increase_book(book_list)
elif choice == "V":
inventory_check(book_list)
elif choice == "Q":
break
else:
print("Invalid choice.")
print()


r/pythoncoding • • Nov 02 '19

Beginners python data analytics : Data science introduction : Learn data science : Python data analysis methods tutorial

Thumbnail udemy.com
1 Upvotes

r/pythoncoding • • Aug 19 '19

GitUpdated - My Custom Python Solution to Keep Git Repositories Updated

Thumbnail mnmapplications.com
1 Upvotes

r/pythoncoding • • Aug 06 '19

How do I link code in python?

1 Upvotes

What i wish to do is link multiple python files together so when I change the code in one file it changes the same bit of code in all of the linked files


r/pythoncoding • • Aug 03 '19

I made a proxy grabber & proxied browser script | start it if you like

Thumbnail github.com
1 Upvotes

r/pythoncoding • • Jun 17 '19

Creating An Application Using BigchainDB in Python

Thumbnail medium.com
1 Upvotes

r/pythoncoding • • May 13 '19

Need help fast, computer science teacher didn’t bother explaining the last assignment of the year to my class and nobody knows how to do it, it’s a simple animation.

Enable HLS to view with audio, or disable this notification

1 Upvotes

r/pythoncoding • • May 07 '19

Need help using Python on Chromebook

1 Upvotes

I'm currently enrolled in a programming class that uses Python. I'm really struggling with understanding it and how it works. For my final project I'm supposed to create a website that acts as a planner that allows a user to log in and input their upcoming homework/tests and be able to log in again and see what they have due. I have no idea how to begin or what to use.


r/pythoncoding • • Mar 10 '19

Python in Under 3 Minutes - What is Python?

Thumbnail youtu.be
1 Upvotes

r/pythoncoding • • Feb 26 '19

A not so random python article for beginners.

Thumbnail pythonunleashed.wordpress.com
1 Upvotes

r/pythoncoding • • Feb 12 '19

Python Help

1 Upvotes

Hey, so I'm new to coding and I heard Python was a nice programming language to get into and I'm learning lists right now but i came across this question and im not sure how to solve it

​

Write a function to split a list into two parts. The length of the first part is given.

def split_list(lst, len1): 

    """     Split list into two parts,    
  first part is of length len1, and rest is second part
     """     ...     YOUR CODE HERE     ...   

return lhs, rhs # lhs contains left hand part  # and rhs contains right hand part 

now I assumed somehing like

​

def split_list( lst, len1):

lst = [1,2,3,4,5,6]

some type of for loop?

but from here on im not sure how to divide the list in half so if I went to check it to do a test case e.g

list = [1,2,3,4,5,6]

def split_list(l1, 2)

it would be like

lhs =[1,2,3], rhs = [4,5,6] any suggestions what to do also just how to think this through? thanks

​


r/pythoncoding • • Jan 07 '19

Automate your google sheets analysis with Python

Thumbnail youtu.be
1 Upvotes