{"id":759,"date":"2026-10-05T13:35:27","date_gmt":"2026-10-05T18:35:27","guid":{"rendered":"https:\/\/sts.doit.wisc.edu\/training-materials\/?post_type=activity&#038;p=759"},"modified":"2026-10-05T13:35:27","modified_gmt":"2026-10-05T18:35:27","slug":"intro-to-programming","status":"publish","type":"activity","link":"https:\/\/sts.doit.wisc.edu\/training-materials\/activity\/intro-to-programming\/","title":{"rendered":"Intro to Programming"},"content":{"rendered":"\n<section class=\"wp-block-sts-block-sts-custom-sections\">\n<h2 class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are two activities to try for this topic: the first is a simple temperature-converting program, and the second is a number-guessing game.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Both activities are done using Python.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You may complete these activities in an IDE, text editor, paper and pencil, or whatever medium you choose.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you choose to use an IDE, we suggest using <a href=\"http:\/\/online-python.com\" data-type=\"link\" data-id=\"online-python.com\">online-python.com<\/a>, as it is simple and easy to use.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The elements you will likely be using on <a href=\"http:\/\/online-python.com\">online-python.com<\/a> are highlighted here:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"720\" src=\"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-content\/uploads\/2026\/03\/online-python.png\" alt=\"online-python.com elements\" class=\"wp-image-758\" srcset=\"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-content\/uploads\/2026\/03\/online-python.png 960w, https:\/\/sts.doit.wisc.edu\/training-materials\/wp-content\/uploads\/2026\/03\/online-python-300x225.png 300w, https:\/\/sts.doit.wisc.edu\/training-materials\/wp-content\/uploads\/2026\/03\/online-python-768x576.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/figure>\n<\/section>\n\n\n\n<section class=\"wp-block-sts-block-sts-custom-sections\">\n<h2 class=\"wp-block-heading\">Activity 1: Temperature Converter<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Objective<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a program that converts a value from Celsius to Fahrenheit<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Concepts<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Variables, data types, operators<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Steps<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create an integer variable&nbsp;<strong>celsius&nbsp;<\/strong>that holds the value 40<\/li>\n\n\n\n<li>Create an integer variable&nbsp;<strong>fahrenheit&nbsp;<\/strong>that converts the value in&nbsp;<strong>celsius&nbsp;<\/strong>(( _ * 1.8 )+32 )<\/li>\n\n\n\n<li>Print out&nbsp;<strong>celsius<\/strong>&nbsp;and&nbsp;<strong>fahrenheit<\/strong>&nbsp;to the user<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Syntax To Use<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u2026 = &#8230;<\/strong> &#8211; create a variable with a value<\/li>\n\n\n\n<li><strong>print(<\/strong>&#8230;<strong>)<\/strong> &#8211; print value in parenthesis<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Expected Results<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\" data-line=\"\">celsius = 40\n\nfahrenheit = (celsius * 1.8) + 32\n\nprint(celsius)\n\nprint(fahrenheit)<\/code><\/pre>\n<\/section>\n\n\n\n<section class=\"wp-block-sts-block-sts-custom-sections\">\n<h2 class=\"wp-block-heading\">Activity 2: Number Guessing Game<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Objective<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a program where users guess a randomly generated number<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Concepts<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Variables, libraries, loops, operators, data types, conditionals<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Steps<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Import the &#8220;random&#8221; library into your program<\/li>\n\n\n\n<li>Create a variable that holds a random number from 1 to 100<\/li>\n\n\n\n<li>Create a variable that tracks the number of tries a user can make and set it to 10 tries<\/li>\n\n\n\n<li>Create a loop that continues until the user runs out of tries<\/li>\n\n\n\n<li>Decrease the number of tries a user has by 1<\/li>\n\n\n\n<li>Take in the user\u2019s input and store it in a variable<\/li>\n\n\n\n<li>Compare the input to the random number\n<ul class=\"wp-block-list\">\n<li>If the guess is equal to the secret number, print out a statement to the user letting them know they got the answer, and break out of the loop<\/li>\n\n\n\n<li>Otherwise, if the guess is less than the number, print out a statement to the user letting them know it\u2019s too low<\/li>\n\n\n\n<li>Otherwise, if the guess is higher than the number, print out a statement to the user letting them know it\u2019s too high<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Syntax to Use<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>import <\/strong>&#8230; &#8211; import a library to use in your program (make sure this is at the top of your program)<\/li>\n\n\n\n<li><strong>random.randint(<\/strong>low int, high int<strong>) &#8211; <\/strong>use the random library to generate a random number in the given range<\/li>\n\n\n\n<li><strong>\u2026 = &#8230;<\/strong> &#8211; create a variable<\/li>\n\n\n\n<li><strong>while <\/strong>\u2026<strong>:<\/strong> &#8211; loop that runs when the condition is true<\/li>\n\n\n\n<li>&#8230; <strong>-=<\/strong> \u2026 &#8211; decrease a variable by a value<\/li>\n\n\n\n<li><strong>int(input(\u201c<\/strong>&#8230;<strong>\u201d)) <\/strong>&#8211; prints out a statement to the user and converts their input to an integer<\/li>\n\n\n\n<li><strong>if <\/strong>\u2026<strong>\/elif <\/strong>\u2026\/<strong>else:<\/strong> -block that runs if the condition is true<\/li>\n\n\n\n<li><strong>print(<\/strong>&#8230;<strong>)<\/strong> &#8211; print value in parenthesis<\/li>\n\n\n\n<li><strong>break<\/strong> &#8211; exit a loop<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Expected Results<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\" data-line=\"\">import random\nnumber = random.randint(1, 100)\n\ntries = 10\n\nwhile tries &gt; 0:\n    tries -= 1\n    guess = int(input(&quot;Enter a number: &quot;))\n\n    if guess == number:\n        print(&quot;Correct answer!&quot;)\n        break\n    elif guess &lt; number:\n        print(&quot;Your guess is too low!&quot;)\n    else:\n        print(&quot;Your guess is too high!&quot;)<\/code><\/pre>\n<\/section>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"featured_media":0,"template":"","class_list":["post-759","activity","type-activity","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/activity\/759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/activity"}],"about":[{"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/types\/activity"}],"wp:attachment":[{"href":"https:\/\/sts.doit.wisc.edu\/training-materials\/wp-json\/wp\/v2\/media?parent=759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}