Giter Site home page Giter Site logo

lhyljyt / -4-_rpsls_github.txt Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 259 KB

#coding:gbk """ 第一个小项目:rock石头-paper纸-scissors剪刀-lizard蜥蜴-Spock史波克 作者:梁鹤逸 日期:2019.11.13 """ # 0 - 石头 # 1 - 史波克 # 2 - 纸 # 3 - 蜥蜴 # 4 - 剪刀 import random tag=1 list1=['石头','史波克','纸','蜥蜴','剪刀'] # 对程序进行测试 def name_to_number(name):#将用户的游戏选择对象转换为相应的整数 if name=='石头': return 0 elif name=='史波克': return 1 elif name=='纸': return 2 elif name=='蜥蜴': return 3 elif name=='剪刀': return 4 else: print('Error: No Correct Name') def number_to_name(number): if number in range(0,5): if number==0: return 石头 elif number==1: return 史波克 elif number==2: return 纸 elif number==3: return 蜥蜴 elif number==4: return 剪刀 else: print('Error: No Correct Name') def rpsls(player_choice,computer):#用户玩家任意给出一个选择,根据RPSLS游戏规则,在屏幕上输出对应的结果 while tag: list1=['石头','史波克','纸','蜥蜴','剪刀'] list2=[[0,4],[0,3],[1,4],[1,0],[2,0],[2,1],[3,2],[3,1],[4,3],[4,2]] if player_choice in list1: if [player_choice,computer]in list2: print('您赢了') elif player_choice==computer: print('您和计算机出的一样呢') else: print('计算机赢了') else: print('Error: No Correct Name') break print("欢迎使用RPSLS游戏") print("----------------") print("请输入您的选择:") player_choice=input() print("--------") computer=random.choice(list1) print('你的选择为:%s'%(player_choice)) print('计算机的选择为:%s'%(computer)) rpsls(player_choice,computer)#rpsls意为石头剪刀布 # 输出"-------- "进行分割 # 显示用户输入提示,用户通过键盘将自己的游戏选择对象输入,存入变量player_choice # 调用name_to_number()函数将用户的游戏选择对象转换为相应的整数,存入变量player_choice_number # 利用random.randrange()自动产生0-4之间的随机整数,作为计算机随机选择的游戏对象,存入变量comp_number # 调用number_to_name()函数将计算机产生的随机数转换为对应的游戏对象 # 在屏幕上显示计算机选择的随机对象 # 利用if/elif/else 语句,根据RPSLS规则对用户选择和计算机选择进行判断,并在屏幕上显示判断结果 # 如果用户和计算机选择一样,则显示“您和计算机出的一样呢”,如果用户获胜,则显示“您赢了”,反之则显示“计算机赢了” #根据以上提示编写执行代码,代码完成后删除掉pass #list2=[[0,4],[0,3],[1,4],[1,0],[2,0],[2,1],[3,2],[3,1],[4,3],[4,2]] #[['石头','剪刀'],['石头','蜥蜴'],['史波克','剪刀'],['史波克','石头'],['布','石头'],['布','史波克'],['蜥蜴','布'],['蜥蜴','史波克'],['剪刀','蜥蜴'],['剪刀','布']]

HTML 64.35% CSS 35.65%

-4-_rpsls_github.txt's Introduction

Welcome to GitHub

Welcome to GitHub—where millions of developers work together on software. Ready to get started? Let’s learn how this all works by building and publishing your first GitHub Pages website!

Repositories

Right now, we’re in your first GitHub repository. A repository is like a folder or storage space for your project. Your project's repository contains all its files such as code, documentation, images, and more. It also tracks every change that you—or your collaborators—make to each file, so you can always go back to previous versions of your project if you make any mistakes.

This repository contains three important files: The HTML code for your first website on GitHub, the CSS stylesheet that decorates your website with colors and fonts, and the README file. It also contains an image folder, with one image file.

Describe your project

You are currently viewing your project's README file. README files are like cover pages or elevator pitches for your project. They are written in plain text or Markdown language, and usually include a paragraph describing the project, directions on how to use it, who authored it, and more.

Learn more about READMEs

Your first website

GitHub Pages is a free and easy way to create a website using the code that lives in your GitHub repositories. You can use GitHub Pages to build a portfolio of your work, create a personal website, or share a fun project that you coded with the world. GitHub Pages is automatically enabled in this repository, but when you create new repositories in the future, the steps to launch a GitHub Pages website will be slightly different.

Learn more about GitHub Pages

Rename this repository to publish your site

We've already set-up a GitHub Pages website for you, based on your personal username. This repository is called hello-world, but you'll rename it to: username.github.io, to match your website's URL address. If the first part of the repository doesn’t exactly match your username, it won’t work, so make sure to get it right.

Let's get started! To update this repository’s name, click the Settings tab on this page. This will take you to your repository’s settings page.

repo-settings-image

Under the Repository Name heading, type: username.github.io, where username is your username on GitHub. Then click Rename—and that’s it. When you’re done, click your repository name or browser’s back button to return to this page.

rename_screenshot

Once you click Rename, your website will automatically be published at: https://your-username.github.io/. The HTML file—called index.html—is rendered as the home page and you'll be making changes to this file in the next step.

Congratulations! You just launched your first GitHub Pages website. It's now live to share with the entire world

Making your first edit

When you make any change to any file in your project, you’re making a commit. If you fix a typo, update a filename, or edit your code, you can add it to GitHub as a commit. Your commits represent your project’s entire history—and they’re all saved in your project’s repository.

With each commit, you have the opportunity to write a commit message, a short, meaningful comment describing the change you’re making to a file. So you always know exactly what changed, no matter when you return to a commit.

Practice: Customize your first GitHub website by writing HTML code

Want to edit the site you just published? Let’s practice commits by introducing yourself in your index.html file. Don’t worry about getting it right the first time—you can always build on your introduction later.

Let’s start with this template:

<p>Hello World! I’m [username]. This is my website!</p>

To add your introduction, copy our template and click the edit pencil icon at the top right hand corner of the index.html file.

edit-this-file

Delete this placeholder line:

<p>Welcome to your first GitHub Pages website!</p>

Then, paste the template to line 15 and fill in the blanks.

edit-githuboctocat-index

When you’re done, scroll down to the Commit changes section near the bottom of the edit page. Add a short message explaining your change, like "Add my introduction", then click Commit changes.

add-my-username

Once you click Commit changes, your changes will automatically be published on your GitHub Pages website. Refresh the page to see your new changes live in action.

🎉 You just made your first commit! 🎉

Extra Credit: Keep on building!

Change the placeholder Octocat gif on your GitHub Pages website by creating your own personal Octocat emoji or choose a different Octocat gif from our logo library here. Add that image to line 12 of your index.html file, in place of the <img src= link.

Want to add even more code and fun styles to your GitHub Pages website? Follow these instructions to build a fully-fledged static website.

octocat

Everything you need to know about GitHub

Getting started is the hardest part. If there’s anything you’d like to know as you get started with GitHub, try searching GitHub Help. Our documentation has tutorials on everything from changing your repository settings to configuring GitHub from your command line.

-4-_rpsls_github.txt's People

Contributors

lhyljyt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.