0% found this document useful (0 votes)
9 views3 pages

Variables Assignment Programming Guide

The document outlines a series of programming problems focused on variable assignment and usage in Python. It includes tasks such as printing names in different orders, performing arithmetic operations with integers, creating a receipt-like output for cafeteria items, drawing concentric circles, and manipulating graphical elements. Each problem emphasizes proper variable naming and formatting in the output.

Uploaded by

haroonriaz116
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Variables Assignment Programming Guide

The document outlines a series of programming problems focused on variable assignment and usage in Python. It includes tasks such as printing names in different orders, performing arithmetic operations with integers, creating a receipt-like output for cafeteria items, drawing concentric circles, and manipulating graphical elements. Each problem emphasizes proper variable naming and formatting in the output.

Uploaded by

haroonriaz116
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Variables Assignment

Start each program with a comment that states the name of the program, the problem number,
your name, the date and a description of the program, as follows:
# Variables - Problem 1
# Your Name
# Date: XX/XX/XXX
# This is a description

Make sure that you use proper, descriptive variable names by following the naming conventions
described earlier in this module.
Save each program with a descriptive file name such as [Link].

Variables - Problem 1

Write a program that assigns your first, middle and last names
to three different variables. Then print out your name in 4
different orders using the variables in the print statement. ​
Ex. If a person’s name was Sidney Taylor Devoy, the output
would be like the example to the right:

Variables - Problem 2 (Choose either this or Problem 3)

Write a program that declares 2 integer variables.


Set the 2 variables to be any positive integers you
would like. Output the values of the 2 variables in a
sentence on one line of the computer screen. Output
the sum of the 2 variables in an equation. Output the
difference (subtraction) of the 2 variables in an
equation. Output the product (multiplication) of the 2
variables in an equation. Output the quotient (division) of the 2 variables in an equation,
displaying exactly two decimal places. (Use formatting or rounding)!

Variables - Problem 3 (Choose either this or Problem 2)

Write a program that uses variables to store the names and prices of
three items that you could buy in the school cafeteria. The program
should output the name and cost of each of the items next to each
other on the computer screen. Below the items, display the total cost
(the computer should add up the prices). The result should look a bit
like a receipt.

Currency = "${:,.2f}".format(amount);
Variables - Problem 4

●​ Write a program that draws concentric circles on a 400 X 400


Graphics Window.
●​ Use a variable for the center x, a variable for the center y and a
variable for the radius.
●​ Assign the value of 200 to the center x variable, 200 to the
center y variable, and 200 to the radius
●​ Draw a circle using the variable names. Then change the value
of the radius variable to draw 3 more circles of different sizes.

Variables - Problem 5 (Challenge)


Copy and paste the following program into Python and run it.

from graphics import *

# Creates your window for drawing


win=GraphWin("My Graphics",400,400);

x=10;
y=10;
sideLength=50;

aBox=Rectangle(Point(x,y) ,Point(x+sideLength,y+sideLength));
[Link]("blue");
[Link](win);

Experiment with changing the values of x and y. Then experiment with changing the value of
sideLength.

Write a program that uses a variable for the x, y and sideLength. Assign the value 10 to x, the
value 10 to y and the value 50 to sideLength. Draw 3 squares as shown below. Attempt to draw
the squares without changing the values stored in the variables - just use a bit of math in the
lines of code that define the rectangles.

If you have done this correctly changing x or y


will not change the shape. It will simply move
the pattern to another spot on the screen.
Changing the value of sideLength will change
the size but not the shape.

You might also like