Hướng dẫn best python projects for beginners - dự án python tốt nhất cho người mới bắt đầu

Mục lục

AI, ML và Khoa học dữ liệu thống trị nhiều lĩnh vực và ngành công nghiệp ngày nay - tất cả chúng đều sử dụng rất nhiều ngôn ngữ lập trình Python theo cách này hay cách khác. & NBSP;

Trở thành một bậc thầy trong Python có thể mở ra nhiều cánh cửa trong sự nghiệp của bạn và hạ cánh trong một số cơ hội tốt nhất trên khắp hành tinh. Bất cứ nơi nào bạn đánh giá bản thân trong kỹ năng Python, làm việc trên các dự án Python là một cách chắc chắn để tăng cường các kỹ năng của bạn và xây dựng hồ sơ của bạn. Trong khi các cuốn sách Python và hướng dẫn Python rất hữu ích, không có gì đánh bại làm cho tay bạn bẩn với mã hóa thực tế.

Chúng tôi liệt kê một số dự án Python cho người mới bắt đầu để bạn thử thách bản thân và trở nên tốt hơn trong mã hóa Python.

Top 10 ý tưởng dự án Python cho người mới bắt đầu

1. Máy phát điện Mad Libs & NBSP;

Dự án người mới bắt đầu Python này là một khởi đầu tốt cho người mới bắt đầu vì nó sử dụng các chuỗi, biến và nối. Máy phát điện Mad Libs thao tác dữ liệu đầu vào, có thể là bất cứ điều gì: tính từ, đại từ hoặc động từ. Sau khi tham gia vào đầu vào, chương trình lấy dữ liệu và sắp xếp nó để xây dựng một câu chuyện. Đây là một dự án Python rất tuyệt vời để thử nếu bạn mới sử dụng mã hóa.

Mã mẫu:

""" Mad Libs Generator

----------------------------------------

"""

#Loop back to this point once code finishes

loop = 1

while (loop < 10):

# All the questions that the program asks the user

noun = input("Choose a noun: ")

p_noun = input("Choose a plural noun: ")

noun2 = input("Choose a noun: ")

place = input("Name a place: ")

adjective = input("Choose an adjective (Describing word): ")

noun3 = input("Choose a noun: ")

#Displays the story based on the users input

print ("------------------------------------------")

print ("Be kind to your",noun,"- footed", p_noun)

print ("For a duck may be somebody's", noun2,",")

print ("Be kind to your",p_noun,"in",place)

print ("Where the weather is always",adjective,".")

print ()

print ("You may think that is this the",noun3,",")

print ("Well it is.")

print ("------------------------------------------")

# Loop back to "loop = 1"

loop = loop + 1

2. Đoán số & nbsp;

Dự án này là một trò chơi thú vị tạo ra một số ngẫu nhiên trong một phạm vi được chỉ định nhất định và người dùng phải đoán số sau khi nhận được gợi ý. Mỗi khi người dùng đoán là sai, họ được nhắc nhở với nhiều gợi ý hơn để làm cho nó dễ dàng hơn - với chi phí giảm điểm số.

Chương trình cũng yêu cầu các chức năng kiểm tra xem một số thực được nhập bởi người dùng và tìm thấy sự khác biệt giữa hai số. & NBSP;

Mã mẫu:

""" Number Guessing Game

----------------------------------------

"""

import random

attempts_list = []

def show_score():

if len(attempts_list) <= 0:

print("There is currently no high score, it's yours for the taking!")

else:

print("The current high score is {} attempts".format(min(attempts_list)))

def start_game():

random_number = int(random.randint(1, 10))

print("Hello traveler! Welcome to the game of guesses!")

player_name = input("What is your name? ")

wanna_play = input("Hi, {}, would you like to play the guessing game? (Enter Yes/No) ".format(player_name))

# Where the show_score function USED to be

attempts = 0

show_score()

while wanna_play.lower() == "yes":

try:

guess = input("Pick a number between 1 and 10 ")

if int(guess) < 1 or int(guess) > 10:

raise ValueError("Please guess a number within the given range")

if int(guess) == random_number:

print("Nice! You got it!")

attempts += 1

attempts_list.append(attempts)

print("It took you {} attempts".format(attempts))

play_again = input("Would you like to play again? (Enter Yes/No) ")

attempts = 0

show_score()

random_number = int(random.randint(1, 10))

if play_again.lower() == "no":

print("That's cool, have a good one!")

break

elif int(guess) > random_number:

print("It's lower")

attempts += 1

elif int(guess) < random_number:

print("It's higher")

attempts += 1

except ValueError as err:

print("Oh no!, that is not a valid value. Try again...")

print("({})".format(err))

else:

print("That's cool, have a good one!")

if __name__ == '__main__':

start_game()

2. Đoán số & nbsp;

Dự án này là một trò chơi thú vị tạo ra một số ngẫu nhiên trong một phạm vi được chỉ định nhất định và người dùng phải đoán số sau khi nhận được gợi ý. Mỗi khi người dùng đoán là sai, họ được nhắc nhở với nhiều gợi ý hơn để làm cho nó dễ dàng hơn - với chi phí giảm điểm số.

  • Chương trình cũng yêu cầu các chức năng kiểm tra xem một số thực được nhập bởi người dùng và tìm thấy sự khác biệt giữa hai số. & NBSP; to generate rock, paper, or scissors. 
  • 3. Kéo giấy đáto check the validity of the move.
  • Chương trình kéo giấy đá này sử dụng một số chức năng vì vậy đây là một cách tốt để có được khái niệm quan trọng đó trong vành đai của bạn. to declare the winner of the round.
  • Hàm ngẫu nhiên: để tạo đá, giấy hoặc kéo. & Nbsp;to keep track of the score.

Hàm hợp lệ: Để kiểm tra tính hợp lệ của việc di chuyển.

Mã mẫu:

""" Rock Paper Scissors

----------------------------------------

"""

import random

import os

import re

os.system('cls' if os.name=='nt' else 'clear')

while (1 < 2):

print ("\n")

print ("Rock, Paper, Scissors - Shoot!")

userChoice = input("Choose your weapon [R]ock], [P]aper, or [S]cissors: ")

if not re.match("[SsRrPp]", userChoice):

print ("Please choose a letter:")

print ("[R]ock, [S]cissors or [P]aper.")

continue

# Echo the user's choice

print ("You chose: " + userChoice)

choices = ['R', 'P', 'S']

opponenetChoice = random.choice(choices)

print ("I chose: " + opponenetChoice)

if opponenetChoice == str.upper(userChoice):

print ("Tie! ")

#if opponenetChoice == str("R") and str.upper(userChoice) == "P"

elif opponenetChoice == 'R' and userChoice.upper() == 'S':

print ("Scissors beats rock, I win! ")

continue

elif opponenetChoice == 'S' and userChoice.upper() == 'P':

print ("Scissors beats paper! I win! ")

continue

elif opponenetChoice == 'P' and userChoice.upper() == 'R':

print ("Paper beat rock, I win!")

continue

else:

print ("You win!")

2. Đoán số & nbsp;

Dự án này là một trò chơi thú vị tạo ra một số ngẫu nhiên trong một phạm vi được chỉ định nhất định và người dùng phải đoán số sau khi nhận được gợi ý. Mỗi khi người dùng đoán là sai, họ được nhắc nhở với nhiều gợi ý hơn để làm cho nó dễ dàng hơn - với chi phí giảm điểm số.

Mã mẫu:

import random

#Enter the minimum and maximum limits of the dice rolls below

min_val = 1

max_val = 6

#the variable that stores the user’s decision

roll_again = "yes"

#The dice roll loop if the user wants to continue

while roll_again == "yes" or roll_again == "y":

print("Dices rolling...")

print("The values are :")

#Printing the randomly generated variable of the first dice

print(random.randint(min_val, max_val))

#Printing the randomly generated variable of the second dice

print(random.randint(min_val, max_val))

#Here the user enters yes or y to continue and any other input ends the program

roll_again = input("Roll the Dices Again?")

2. Đoán số & nbsp;

Dự án này là một trò chơi thú vị tạo ra một số ngẫu nhiên trong một phạm vi được chỉ định nhất định và người dùng phải đoán số sau khi nhận được gợi ý. Mỗi khi người dùng đoán là sai, họ được nhắc nhở với nhiều gợi ý hơn để làm cho nó dễ dàng hơn - với chi phí giảm điểm số.

Chương trình cũng yêu cầu các chức năng kiểm tra xem một số thực được nhập bởi người dùng và tìm thấy sự khác biệt giữa hai số. & NBSP;

Mã mẫu:

# Recursive Binary Search algorithm in Python

def binarySearch(array, x, low, high):

if high >= low:

mid = low + (high - low)//2

# If found at mid, return the value

if array[mid] == x:

return mid

# Search the first half

elif array[mid] > x:

return binarySearch(array, x, low, mid-1)

# Search the second half

else:

return binarySearch(array, x, mid + 1, high)

else:

return -1

array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

x = int(input("Enter a number between 1 and 10:"))

result = binarySearch(array, x, 0, len(array)-1)

if result != -1:

print("Element is present at position" + str(result))

else:

print("Element not found")

2. Đoán số & nbsp;

Dự án này là một trò chơi thú vị tạo ra một số ngẫu nhiên trong một phạm vi được chỉ định nhất định và người dùng phải đoán số sau khi nhận được gợi ý. Mỗi khi người dùng đoán là sai, họ được nhắc nhở với nhiều gợi ý hơn để làm cho nó dễ dàng hơn - với chi phí giảm điểm số.

Mã mẫu:

# Calculator

def addition ():

print("Addition")

n = float(input("Enter the number: "))

t = 0 #Total number enter

ans = 0

while n != 0:

ans = ans + n

t+=1

n = float(input("Enter another number (0 to calculate): "))

return [ans,t]

def subtraction ():

print("Subtraction");

n = float(input("Enter the number: "))

t = 0 #Total number enter

sum = 0

while n != 0:

ans = ans - n

t+=1

n = float(input("Enter another number (0 to calculate): "))

return [ans,t]

def multiplication ():

print("Multiplication")

n = float(input("Enter the number: "))

t = 0 #Total number enter

ans = 1

while n != 0:

ans = ans * n

t+=1

n = float(input("Enter another number (0 to calculate): "))

return [ans,t]

def average():

an = []

an = addition()

t = an[1]

a = an[0]

ans = a / t

return [ans,t]

# main...

while True:

list = []

print(" My first python program!")

print(" Simple Calculator in python by Malik Umer Farooq")

print(" Enter 'a' for addition")

print(" Enter 's' for substraction")

print(" Enter 'm' for multiplication")

print(" Enter 'v' for average")

print(" Enter 'q' for quit")

c = input(" ")

if c != 'q':

if c == 'a':

list = addition()

print("Ans = ", list[0], " total inputs ",list[1])

elif c == 's':

list = subtraction()

print("Ans = ", list[0], " total inputs ",list[1])

elif c == 'm':

list = multiplication()

print("Ans = ", list[0], " total inputs ",list[1])

elif c == 'v':

list = average()

print("Ans = ", list[0], " total inputs ",list[1])

else:

print ("Sorry, invilid character")

else:

break

2. Đoán số & nbsp;

Dự án này là một trò chơi thú vị tạo ra một số ngẫu nhiên trong một phạm vi được chỉ định nhất định và người dùng phải đoán số sau khi nhận được gợi ý. Mỗi khi người dùng đoán là sai, họ được nhắc nhở với nhiều gợi ý hơn để làm cho nó dễ dàng hơn - với chi phí giảm điểm số.

Mã mẫu:

""" Alarm Clock

----------------------------------------

"""

import datetime

import os

import time

import random

import webbrowser

# If video URL file does not exist, create one

if not os.path.isfile("youtube_alarm_videos.txt"):

print('Creating "youtube_alarm_videos.txt"...')

with open("youtube_alarm_videos.txt", "w") as alarm_file:

alarm_file.write("https://www.youtube.com/watch?v=anM6uIZvx74")

def check_alarm_input(alarm_time):

"""Checks to see if the user has entered in a valid alarm time"""

if len(alarm_time) == 1: # [Hour] Format

if alarm_time[0] < 24 and alarm_time[0] >= 0:

return True

if len(alarm_time) == 2: # [Hour:Minute] Format

if alarm_time[0] < 24 and alarm_time[0] >= 0 and \

alarm_time[1] < 60 and alarm_time[1] >= 0:

return True

elif len(alarm_time) == 3: # [Hour:Minute:Second] Format

if alarm_time[0] < 24 and alarm_time[0] >= 0 and \

alarm_time[1] < 60 and alarm_time[1] >= 0 and \

alarm_time[2] < 60 and alarm_time[2] >= 0:

return True

return False

# Get user input for the alarm time

print("Set a time for the alarm (Ex. 06:30 or 18:30:00)")

while True:

alarm_input = input(">> ")

try:

alarm_time = [int(n) for n in alarm_input.split(":")]

if check_alarm_input(alarm_time):

break

else:

raise ValueError

except ValueError:

print("ERROR: Enter time in HH:MM or HH:MM:SS format")

# Convert the alarm time from [H:M] or [H:M:S] to seconds

seconds_hms = [3600, 60, 1] # Number of seconds in an Hour, Minute, and Second

alarm_seconds = sum([a*b for a,b in zip(seconds_hms[:len(alarm_time)], alarm_time)])

# Get the current time of day in seconds

now = datetime.datetime.now()

current_time_seconds = sum([a*b for a,b in zip(seconds_hms, [now.hour, now.minute, now.second])])

# Calculate the number of seconds until alarm goes off

time_diff_seconds = alarm_seconds - current_time_seconds

# If time difference is negative, set alarm for next day

if time_diff_seconds < 0:

time_diff_seconds += 86400 # number of seconds in a day

# Display the amount of time until the alarm goes off

print("Alarm set to go off in %s" % datetime.timedelta(seconds=time_diff_seconds))

# Sleep until the alarm goes off

time.sleep(time_diff_seconds)

# Time for the alarm to go off

print("Wake Up!")

# Load list of possible video URLs

with open("youtube_alarm_videos.txt", "r") as alarm_file:

videos = alarm_file.readlines()

# Open a random video from the list

webbrowser.open(random.choice(videos))

2. Đoán số & nbsp;

Dự án này là một trò chơi thú vị tạo ra một số ngẫu nhiên trong một phạm vi được chỉ định nhất định và người dùng phải đoán số sau khi nhận được gợi ý. Mỗi khi người dùng đoán là sai, họ được nhắc nhở với nhiều gợi ý hơn để làm cho nó dễ dàng hơn - với chi phí giảm điểm số.

Chương trình cũng yêu cầu các chức năng kiểm tra xem một số thực được nhập bởi người dùng và tìm thấy sự khác biệt giữa hai số. & NBSP;

""" Tic Tac Toe

----------------------------------------

"""

import random

import sys

board=[i for i in range(0,9)]

player, computer = '',''

# Corners, Center and Others, respectively

moves=((1,7,3,9),(5,),(2,4,6,8))

# Winner combinations

winners=((0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6))

# Table

tab=range(1,10)

def print_board():

x=1

for i in board:

end = ' | '

if x%3 == 0:

end = ' \n'

if i != 1: end+='---------\n';

char=' '

if i in ('X','O'): char=i;

x+=1

print(char,end=end)

def select_char():

chars=('X','O')

if random.randint(0,1) == 0:

return chars[::-1]

return chars

def can_move(brd, player, move):

if move in tab and brd[move-1] == move-1:

return True

return False

def can_win(brd, player, move):

places=[]

x=0

for i in brd:

if i == player: places.append(x);

x+=1

win=True

for tup in winners:

win=True

for ix in tup:

if brd[ix] != player:

win=False

break

if win == True:

break

return win

def make_move(brd, player, move, undo=False):

if can_move(brd, player, move):

brd[move-1] = player

win=can_win(brd, player, move)

if undo:

brd[move-1] = move-1

return (True, win)

return (False, False)

# AI goes here

def computer_move():

move=-1

# If I can win, others do not matter.

for i in range(1,10):

if make_move(board, computer, i, True)[1]:

move=i

break

if move == -1:

# If player can win, block him.

for i in range(1,10):

if make_move(board, player, i, True)[1]:

move=i

break

if move == -1:

# Otherwise, try to take one of desired places.

for tup in moves:

for mv in tup:

if move == -1 and can_move(board, computer, mv):

move=mv

break

return make_move(board, computer, move)

def space_exist():

return board.count('X') + board.count('O') != 9

player, computer = select_char()

print('Player is [%s] and computer is [%s]' % (player, computer))

result='%%% Deuce ! %%%'

while space_exist():

print_board()

print('#Make your move ! [1-9] : ', end='')

move = int(input())

moved, won = make_move(board, player, move)

if not moved:

print(' >> Invalid number ! Try again !')

continue

if won:

result='*** Congratulations ! You won ! ***'

break

elif computer_move()[1]:

result='=== You lose ! =='

break;

print_board()

print(result)

3. Kéo giấy đá

Chương trình kéo giấy đá này sử dụng một số chức năng vì vậy đây là một cách tốt để có được khái niệm quan trọng đó trong vành đai của bạn.

Mã mẫu:

import time

# The countdown function is defined below

def countdown(t):

while t:

mins, secs = divmod(t, 60)

timer = '{:02d}:{:02d}'.format(mins, secs)

print(timer, end="\r")

time.sleep(1)

t -= 1

print('Lift off!')

# Ask the user to enter the countdown period in seconds

t = input("Enter the time in seconds: ")

# function call

countdown(int(t))

2. Đoán số & nbsp;

Dự án này là một trò chơi thú vị tạo ra một số ngẫu nhiên trong một phạm vi được chỉ định nhất định và người dùng phải đoán số sau khi nhận được gợi ý. Mỗi khi người dùng đoán là sai, họ được nhắc nhở với nhiều gợi ý hơn để làm cho nó dễ dàng hơn - với chi phí giảm điểm số.

Mã mẫu:

def merge_sort (unort_list):

Nếu Len (Untort_list)

trả lại chưa phân loại_list

# Tìm điểm giữa và chia danh sách thành hai

middle = len (unsed_list) // 2

left_list = unort_list [: middle]

right_list = unort_list [giữa:]

left_list = merge_sort (left_list)

right_list = merge_sort (right_list)

Danh sách trả lại (hợp nhất (trái_LIST, RIGHT_LIST))

# Hợp nhất các nửa được sắp xếp

Def Merge (trái_HALF, RIGHT_HALF):

res = []

trong khi len (trái_HALF)! = 0 và len (right_half)! = 0:

Nếu trái_HALF [0]

res.append(left_half[0])

left_half.remove(left_half[0])

else:

res.append(right_half[0])

right_half.remove(right_half[0])

Nếu len (trái_HALF) == 0:

res = res + right_half

else:

res = res + left_half

Trả lại res

Untort_list = [64, 34, 25, 12, 22, 11, 90]

print(merge_sort(unsorted_list))

Kết luận & nbsp;

Có bạn đi - mười dự án Python mới bắt đầu có thể rất nhiều niềm vui cùng một lúc. Các dự án này đưa Python lý thuyết của bạn học bài kiểm tra và giúp xử lý thực tế của bạn về kiến ​​thức Python. & NBSP;

Nếu bạn muốn có một khóa học tốt về việc xây dựng các ứng dụng Python, Python Mega Course: Xây dựng 10 ứng dụng trong thế giới thực là một ứng dụng được đánh giá cao và được đề xuất. Bạn cũng nên xem các câu hỏi phỏng vấn Python để chuẩn bị thêm. & NBSP;

Các câu hỏi thường gặp

1. Tôi nên xây dựng các dự án Python nào để có được một công việc?

Sự thật là bạn cần phải làm nhiều hơn các dự án mới bắt đầu này để có được một công việc. Đầu tiên, bạn nên tập trung vào việc có được những điều cơ bản. Các dự án như loại hợp nhất và máy tính đi qua một số khái niệm quan trọng này. Khi bạn đạt đến cấp trung gian, bạn có thể bắt đầu tập trung vào các dự án sẽ giúp bạn tìm được một công việc.

2. Một số dự án Python tốt là gì?

Đối với người mới bắt đầu, các loại hợp nhất, máy tính, tic-tac-toe và các dự án thuật toán tìm kiếm nhị phân là nơi tốt để bắt đầu. Tuy nhiên, tất cả các dự án trong danh sách này đều đáng để thực hiện, vì tất cả chúng đều có một cái gì đó để cung cấp.

3. Làm cách nào để bắt đầu dự án Python đầu tiên của tôi?

Bằng cách thực sự mã hóa! Không có cách nào khác để làm điều đó. Bạn bắt đầu dự án Python đầu tiên của bạn bằng cách thực sự thử mã.

Mọi người cũng đang đọc:

  • Các khóa học Python tốt nhất
  • Chứng nhận Python tốt nhất
  • Python ide tốt nhất
  • Trình biên dịch Python tốt nhất
  • Thông dịch viên Python tốt nhất
  • Cách tốt nhất để học Python
  • Làm thế nào để chạy một kịch bản Python?
  • Pycharm là gì?
  • Python cho khoa học dữ liệu
  • Thư viện Python hàng đầu

Làm cách nào để bắt đầu dự án Python đầu tiên của tôi?

Hello World: Tạo chương trình Python đầu tiên của bạn..
Bước 1) Mở trình soạn thảo Pycharm. ....
Bước 2) Bạn sẽ cần chọn một vị trí ..
Bước 3) Bây giờ hãy chuyển đến menu của tập tin trên mạng và chọn mới. ....
Bước 5) Bây giờ nhập một chương trình đơn giản - in ('Xin chào thế giới! ....
Bước 6) Bây giờ đi đến menu chạy trên mạng và chọn Run Run để chạy chương trình của bạn ..

Những dự án lớn sử dụng Python?

Các dự án Python cơ bản..
Dự án Hangman ở Python. ....
Trò chơi Python Paper Paper Python. ....
Xúc xắc cuộn mô phỏng trong Python. ....
Dự án máy cắt email. ....
Trò chơi Python của Mad Libs. ....
Thông báo mã hóa mã hóa trong dự án Python. ....
Trò chơi Magic 8 Ball. ....
Trò chơi thực hành mục tiêu ..

Tôi có thể kiếm tiền như một người mới bắt đầu trong Python không?

Vâng, tôi không nói đùa, điều này là hoàn toàn có thật, bất kỳ ai cũng có người mới bắt đầu có thể kiếm tiền bằng Python hoặc bất kỳ ngôn ngữ công nghệ/lập trình nào khác.Chúng tôi không nói dối, hôm nay, chúng tôi sẽ nói với bạn 10 phương pháp làm việc thực tế và 100% sử dụng mà bất cứ ai từ bất cứ nơi nào cũng có thể kiếm tiền.anyone even a beginner can money with Python or any other technology/programming language. We are not lying, today, we are going to tell you the top 10 real and 100% working methods using which anyone from anywhere can make money.

Các dự án mã hóa người mới bắt đầu tốt là gì?

Top 9 dự án mã hóa cho người mới bắt đầu..
Xây dựng một ứng dụng đơn giản.....
Phát triển một trò chơi cơ bản bằng cách sử dụng JavaScript.....
Tạo một công cụ đơn giản.....
Xây dựng một trang web cơ bản bằng cách sử dụng HTML và CSS.....
Đóng góp cho một dự án nguồn mở.....
Phát triển trò chơi cờ vua của riêng bạn trong Java.....
Tạo máy tính của riêng bạn.....
Thiết kế lại một trang web ..