🐍

Python projects for beginnersですぞ

2021/02/08に公開

https://dev.to/mindninjax/acronym-generator-beginner-python-project-source-code-49h1

から2つお試し。

https://github.com/mindninjaX/Python-Projects-for-Beginners

Acronym generator

https://github.com/mindninjaX/Python-Projects-for-Beginners/blob/master/Acronyms Generator/Acronyms Generator.py

user_input = input("Enter a phrase: ")

phrase = (user_input.replace('of', '')).split()

acronym = ""

for word in phrase:
    acronym = acronym + word[0].upper()

print(f'Acronym of {user_input} is {acronym}')
Enter a phrase: works human intelligence
Acronym of works human intelligence is WHI

Dice Roller

https://github.com/mindninjaX/Python-Projects-for-Beginners/blob/master/Dice Roller/Dice Roller.py

# Importing randome module
import random

# Initiating an while loop to keep the program executing
while True:
    print("Rolling Dice...")

    # Using random.randint(1,6) to generate a random value between 1 & 6
    print(f"The value is ", random.randint(1,6))

    # Asking user to roll the dice again or quit 
    repeat = input("Roll Dice again? 'y' for yes & 'n' for no: ")

    # If the user answers negative the loop will break and program execution stops otherwise the program will continue executing 
    if repeat == 'n':
        break

Discussion