<> preface

in use Python In the process of , What I like best is Python Various third-party libraries , Able to complete many operations .

Now let's introduce 5 Passed Python Built project , To learn Python programming .

<> one , Stone scissors paper game

target : Create a command line game , Players can play in rocks , Choose between scissors and cloth , With computers PK. If the player wins , Scores will be added , until

At the end of the game , The final score will be displayed to the player .

Tips : Receive player's selection , And compare with the choice of the computer . The computer's selection is randomly selected from the selection list . If the player wins , Then increase 1

branch .
Python exchange of learning Q group 906715085 import random choices = ["Rock", "Paper", "Scissors"]
computer= random.choice(choices) player = False cpu_score = 0 player_score = 0
while True: player = input("Rock, Paper or Scissors?").capitalize() #
Judge the choice of players and computers if player == computer: print("Tie!") elif player == "Rock": if
computer== "Paper": print("You lose!", computer, "covers", player) cpu_score+=1
else: print("You win!", player, "smashes", computer) player_score+=1 elif player
== "Paper": if computer == "Scissors": print("You lose!", computer, "cut",
player) cpu_score+=1 else: print("You win!", player, "covers", computer)
player_score+=1 elif player == "Scissors": if computer == "Rock": print("You
lose...", computer, "smashes", player) cpu_score+=1 else: print("You win!",
player, "cut", computer) player_score+=1 elif player=='E': print("Final Scores:"
) print(f"CPU:{cpu_score}") print(f"Plaer:{player_score}") break else: print(
"That's not a valid play. Check your spelling!") computer = random.choice(
choices)
<> two , Random Password Generator

target : Create a program , Password length can be specified , Generate a string of random passwords .

Tips : Create a number + capital + Lowercase letters + String of special characters . Randomly generate a string of passwords according to the set password length .
import random passlen = int(input("enter the length of password" )) s="
abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKL MNOPQRSTUVIXYZ!aN$x*6*( )?" p
= ".join(random.sample(s,passlen )) print(p) ---------------------------- enter
the length of password6 Za1gB0

<> three , Dice simulator

objective : Create a program to simulate rolling dice .

Tips : When the user asks , use random Module generates a 1 reach 6 Number between .
import random; while int(input('Press 1 to roll the dice or 0 to exit:\n')):
print( random. randint(1,6)) ---------------------------------------------------
----------------- Press 1 to roll the dice or 0 to exit 1 4
<> four , Send mail automatically

objective : Write a Python script , You can use this script to send emails .

Tips :email Library can be used to send e-mail .
Python exchange of learning Q group :906715085#### import smtplib from email.message import
EmailMessage email= EmailMessage() ## Creating a object for EmailMessage email[
'from'] = 'xyz name' ## Person who is sending email['to'] = 'xyz id' ## Whom we
are sending email['subject'] = 'xyz subject' ## Subject of email email.
set_content("Xyz content of email") ## content of email with smtlib.SMTP(host=
'smtp.gmail.com',port=587)as smtp: ## sending request to server smtp.ehlo() ##
server object smtp.starttls() ## used to send data between server and client
smtp.login("email_id","Password") ## login id and password of gmail smtp.
send_message(email) ## Sending email print("email send") ## Printing success
message
objective : Create an alarm clock Python script .

Tips : You can use date-time Module creation alarm clock , as well as playsound Library play sound .
from datetime import datetime from playsound import playsound alarm_time =
input("Enter the time of alarm to be set:HH:MM:SS\n") alarm_hour=alarm_time[0:2]
alarm_minute=alarm_time[3:5] alarm_seconds=alarm_time[6:8] alarm_period =
alarm_time[9:11].upper() print("Setting up alarm..") while True: now = datetime.
now() current_hour = now.strftime("%I") current_minute = now.strftime("%M")
current_seconds= now.strftime("%S") current_period = now.strftime("%p") if(
alarm_period==current_period): if(alarm_hour==current_hour): if(alarm_minute==
current_minute): if(alarm_seconds==current_seconds): print("Wake Up!") playsound
('audio.mp3') ## download the alarm sound from link break

<> last

This is the end of today's sharing , The above is for you to share 5 Mini projects , Learned to play all day without getting bored , If you don't believe me, try it . Last last ,

If you like it, remember to give a five-star praise , Remember to comment if you don't understand , I will reply when I see it .

Technology
©2019-2020 Toolsou All rights reserved,
【C++ Must see for entry 】C++ from 0 reach 1 Introductory programming axios Interceptor packaging and use Spring Boot Interview must ask : Automatic configuration principle VMware 16 install centos 7 Detailed tutorial C Language data structure - Sequence table delete duplicates V2.0.0 The 12th Blue Bridge Cup c++b Group personal problem solving On sending data from serial port single chip microcomputer to upper computer centos7 install RabbitMqjava Polymorphic array of opencv-python Fourier transform and inverse transform