Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    7
  • comments
    2
  • views
    1425

my 2nd program in python

Sign in to follow this  
WinterDragon

541 views

tip15 = 0
tip20 = 0
price = input ("how much did your meal cost?")
tip15 = int (price) * .15
tip20 = int (price) * .2
print ("A 20% tip would be ",tip20," and a 15% tip would be",tip15)
input ()

I wrote a tipper program for an exercise.
It's a simple program and it took 20mins to write including several bug fixes,
where I had to go back to looking through the textbook and a few glances at my first program,
before I got it running properly. I made the usual noob mistakes - since I've tackled many different languages, I had to figure out if I needed to declare variables.
I also got the variable on the wrong side of the equals sign, then I forgot to include commas in my print statement for the variables. I also forgot to state that the variable was an integer. Finally, I forgot to use brackets and then incorrectly included the calculation inside the brackets.
Eventually, I figured all of this out and came up with the above seemingly simple program.
And it works!

I'm still not using comments, but I'll fix that when I start writing longer programs.

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By TheAICodeGuy
      Hello everyone!
      If you couldn't figure it out I'm new here. I've been reviewing jobs regarding AI game programming because I love working on AI systems. A few searches have been well straight forward and I'm grateful for that, but for anybody whose has or who still is currently working as an AI programmer, what skills would you say are necessary? I've learned (and still am learning because well learning and getting BETTER never ends) C and C++. Of course I'll continue to sharpen my skills there as much as possible. I've seen some jobs list python and/or lua in their descriptions. Would you say these extra skills are, I guess, major in the game industry? I know python a bit, but lua I don't really know much at all. 
      However I'm most definitely willing to learn.
      Thank you to anyone willing to give feedback!
    • By kalydos
      Currently I have two creative talents with me on board to work with me for my visual novel dating sim and we are currently looking for a programmer to work with in Ren'py (or another program if that works), minimal pixel art and it would require being able to contribute creatively as well as programming a stat/leveling system, affection system, calendar/scheduling activities system, a minimal sidescrolling exploration system and it would also be nice to have a GUI designer. If any clarification or anyone is on board contact me on discord kalydos#0726
    • By renedudfield
      The pygame book project has begun. It's called "pygame 4000" and is a book project by one of the main contributors of the pygame project.

      Not only does the book aim to cover Python programming, but also aims to cover C, and the GLSL shading language.
      [ Pixel Perfect Collision Detection ] [ SDL2 Fundamentals Tutorial in C ] [ Sound Generation and Visualization ] [ Python intro for game programming ] [ Let's make a shit JavaScript Interpreter! ] [ How to port and market games ] [ Let's write a unit test! ] [ Arduino; Serial & pixels for breakfast ] [ Awesome pygame. Great stuff you can use with pygame. ] pygame 4000 available as an early preview pre-release on the pygame book itch page. Updates will be posted on the pygame book developer web log.
      pygame is the most popular game/art/and music library available for the most popular programming language in the world -- Python. pygame is used in school classes, university courses, and workshops around the world. It's used in embedded devices like handheld game consoles, in video synthesizers, museum displays, and interactive art installations. It's available in over 130 different OS distributions, including on the Raspberry Pi, Ubuntu, and MacOS. All funds from the pygame 4000 book go towards pygame development and improvements to the pygame 4000 book.

      View full story
    • By renedudfield
      The pygame book project has begun. It's called "pygame 4000" and is a book project by one of the main contributors of the pygame project.

      Not only does the book aim to cover Python programming, but also aims to cover C, and the GLSL shading language.
      [ Pixel Perfect Collision Detection ] [ SDL2 Fundamentals Tutorial in C ] [ Sound Generation and Visualization ] [ Python intro for game programming ] [ Let's make a shit JavaScript Interpreter! ] [ How to port and market games ] [ Let's write a unit test! ] [ Arduino; Serial & pixels for breakfast ] [ Awesome pygame. Great stuff you can use with pygame. ] pygame 4000 available as an early preview pre-release on the pygame book itch page. Updates will be posted on the pygame book developer web log.
      pygame is the most popular game/art/and music library available for the most popular programming language in the world -- Python. pygame is used in school classes, university courses, and workshops around the world. It's used in embedded devices like handheld game consoles, in video synthesizers, museum displays, and interactive art installations. It's available in over 130 different OS distributions, including on the Raspberry Pi, Ubuntu, and MacOS. All funds from the pygame 4000 book go towards pygame development and improvements to the pygame 4000 book.
    • By Gomta777
      Hello, I am a Japanese, a novice of the python programming.
      I am currently trying to program games using pygame.
      The progress of the game production can be seen on the following blog and youtube channel.
      https://ko-gaku-jiji.hatenablog.jp/
      (sorry all of my page is written by Japanese)

      I'm trying to make a Tetris-like game right now, but sometimes I'm worried.
      In the process for the Tetris game, such as the process of line erasing, I feel that I can write a program more simply by using multithreading.
      However, I couldn't find a suitable sample for multithreading with pygame.
      If you know, please introduce me a web page with a simple and easy-to-understand sample.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!