Created
October 23, 2020 04:56
-
-
Save rahul-bhatt43/63f56382694accf5880776975cd37f2f to your computer and use it in GitHub Desktop.
a simple project using pycharm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Default ignored files | |
/shelf/ | |
/workspace.xml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="InspectionProjectProfileManager"> | |
<settings> | |
<option name="USE_PROJECT_PROFILE" value="false" /> | |
<version value="1.0" /> | |
</settings> | |
</component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" /> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/simplegame.iml" filepath="$PROJECT_DIR$/.idea/simplegame.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="PYTHON_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
</module> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="RunManager"> | |
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true"> | |
<module name="simplegame" /> | |
<option name="INTERPRETER_OPTIONS" value="" /> | |
<option name="PARENT_ENVS" value="true" /> | |
<envs> | |
<env name="PYTHONUNBUFFERED" value="1" /> | |
</envs> | |
<option name="SDK_HOME" value="" /> | |
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> | |
<option name="IS_MODULE_SDK" value="true" /> | |
<option name="ADD_CONTENT_ROOTS" value="true" /> | |
<option name="ADD_SOURCE_ROOTS" value="true" /> | |
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" /> | |
<option name="PARAMETERS" value="" /> | |
<option name="SHOW_COMMAND_LINE" value="false" /> | |
<option name="EMULATE_TERMINAL" value="false" /> | |
<option name="MODULE_MODE" value="false" /> | |
<option name="REDIRECT_INPUT" value="false" /> | |
<option name="INPUT_FILE" value="" /> | |
<method v="2" /> | |
</configuration> | |
</component> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a sample Python script. | |
# Press Shift+F10 to execute it or replace it with your code. | |
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. | |
def print_hi(name): | |
# Use a breakpoint in the code line below to debug your script. | |
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. | |
# Press the green button in the gutter to run the script. | |
if __name__ == '__main__': | |
print_hi('PyCharm') | |
# See PyCharm help at https://www.jetbrains.com/help/pycharm/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import random | |
number = random.randint(1, 10) | |
tries = 0 | |
win = False # setting a win flag to false | |
name = input("Hello, What is your username?") | |
print("Hello" + name + "." ) | |
question = input("Would you like to play a game? [Y/N] ") | |
if question.lower() == "n": #in case of capital letters is entered | |
print("oh..okay") | |
exit() | |
if question.lower() == "y": | |
print("I'm thinking of a number between 1 & 10") | |
while not win: # while the win is not true, run the while loop. We set win to false at the start therefore this will always run | |
guess = int(input("Have a guess: ")) | |
tries = tries + 1 | |
if guess == number: | |
win = True # set win to true when the user guesses correctly. | |
elif guess < number: | |
print("Guess Higher") | |
elif guess > number: | |
print("Guess Lower") | |
# if win is true then output message | |
print("Congrats, you guessed correctly. The number was indeed {}".format(number)) | |
print("it had taken you {} tries".format(tries)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment