Python_ Encapsulation case (soldier assault)

1. Requirement analysis - attributes can be objects created by another class   The properties of an object can be objects created by another class. Xu Sanduo is a Soldier, so we need to define a Soldier class Soldier, and AK47 is a Gun, so we also need to define a Gun class. After the two classes are determined, we will look at the require ...

Added by silrayn on Sat, 04 Sep 2021 23:34:16 +0300

[python Programming] basics 2 - statements: loop, condition, break, pass, continue

This article introduces all statements in python language, judgment statement if, loop statement for and while, as well as break, continue, pass and other statements used. First of all, let's talk about the views of a Han batch who works with C + + (but is not proficient at all) on python programming. As we all know, both conditional and circu ...

Added by noaksey2000 on Sat, 04 Sep 2021 06:44:38 +0300

pytorch | Dragon Boat Festival learning notes

pytorch learning import torch import numpy as np a=torch.rand(4,3,28,28) #torch.rand(batch_size, channel, row, column) a[0].shape #batch_ shape with size = 0: torch.Size([3, 28, 28]) a[0,0].shape #batch_ shape with size = 0 and channel 0: torch.Size([28, 28]) a[0,0,2,4] #batch_size=0, pixels in Row 2 and column 4 on the 0 ...

Added by tacojohn on Sat, 04 Sep 2021 02:45:12 +0300

Python crawler - hands teach you to climb the skin of the king's glory hero

hello everyone! I'm Lin hero You know which is the hottest mobile game at present. Yes, it is the glory of the king. This mobile game must have been heard or played by everyone. There are 106 heroes and hundreds of hero skins. Today I'll teach you to climb down hundreds of skins. catalogue Python Basics Python built-in function zip Python ...

Added by cuvaibhav on Fri, 03 Sep 2021 03:46:08 +0300

Python: Basic operations for files

1. Basic Operation of Files def open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True): Format One open file1 = open('demo1.txt','r') operation file1.write('Hello Python !') Close file1.close() Format 2 Open, operate, close within a structure (automatically close when finished) with open ...

Added by zorgon on Thu, 02 Sep 2021 20:00:46 +0300

Making heart-shaped photo wall with python

Making heart-shaped photo wall with python Hello ~ I'm 36 degrees. Life is short. I use python! Today, share how to make a beautiful heart-shaped photo wall in python effect Let's take a look at the renderings to understand what we need to do next. My renderings are as follows: How do you feel? If you are still satisfied, please give me a ...

Added by The MA on Thu, 02 Sep 2021 07:29:33 +0300

Comparison of prime number screening time between Euler sieve and conventional algorithm

Question: find all prime numbers within 100   This is a very basic and classic small code. It is very likely that we will traverse the filter in this way: def find_odd(numb): flag = 0 if numb ==2: return True else: for i in range(2,numb): flag = 0 if numb%i == 0: retur ...

Added by styler1971 on Thu, 02 Sep 2021 01:24:28 +0300

The first common node of the two linked lists

1, Title Description Enter two acyclic single linked lists and find their first common node( Note: because the incoming data is a linked list, the prompt of error test data is displayed in other ways to ensure that the incoming data is correct) Example 1 Input: {1,2,3}, {4,5}, {6,7} Return value: {6,7} Note: the first parameter {1,2,3} r ...

Added by JennyG on Thu, 02 Sep 2021 00:09:12 +0300

Summarize django knowledge points

1. View functions: Request Object------------- request: 1,HttpRequest.body:) Request original data 2,HttpRequest.path:) A string representing the requested path component (without domain name)           3,HttpRequest.method             4,HttpRequest.GET           5,HttpRequest.POST           6,HttpRequest.FILES 7,HttpResquest.user:) An AUTH_U ...

Added by simon71 on Sun, 19 Jul 2020 17:54:28 +0300

Day 6: TensorFlow2 Model Subclassing API

Custom MLP model structure, 50 generations, total parameters 119690, Mnist test data set accuracy rate of 98%. For neural networks, May Be Paper is better than width. The custom MLP structure is as follows: import numpy as np import tensorflow as tf import os import shutil # mapping from matplotlib im ...

Added by Aphp73 on Tue, 30 Jun 2020 07:10:45 +0300