mirror of
https://github.com/sys-32Dev/CS1010.git
synced 2026-08-08 20:05:59 +00:00
Update and rename createfile to lab4.py
This commit is contained in:
@@ -1 +0,0 @@
|
||||
a
|
||||
68
lab4/lab4.py
Normal file
68
lab4/lab4.py
Normal file
@@ -0,0 +1,68 @@
|
||||
# Part 1
|
||||
|
||||
# set var wombat to 15
|
||||
wombat = 15
|
||||
# prints the stored value in the varible wombat
|
||||
print(wombat)
|
||||
# set var horse to 37
|
||||
horse = 37
|
||||
# set var horsemsg to sring "is the value of horse"
|
||||
horsemsg="is the value of horse"
|
||||
# print horse and horsem on the same line
|
||||
print(horse, horsemsg)
|
||||
# print the sum of var horse and wombat
|
||||
print(horse + wombat)
|
||||
# set var wombat to 10
|
||||
wombat = 10
|
||||
# set var horse to 156
|
||||
horse = 156
|
||||
# print value of var wombat
|
||||
print(wombat)
|
||||
# print value of var horse
|
||||
print(horse)
|
||||
# print sum of var wombat and horse
|
||||
print(wombat + horse)
|
||||
|
||||
|
||||
# Part 2
|
||||
|
||||
|
||||
# set var myString to string "Hello there"
|
||||
myString = "Hello there"
|
||||
# set var yourString to string "Cal State LA."
|
||||
yourString = "Cal State LA."
|
||||
# Prints the combination of var myString and yourString
|
||||
print(myString, yourString)
|
||||
# set var a to 20
|
||||
a = 20
|
||||
# set var b to 2604
|
||||
b = 2604
|
||||
# set var c to the addition of var a and b
|
||||
c = a+b
|
||||
# print var c
|
||||
print(c)
|
||||
|
||||
|
||||
# Part 3
|
||||
|
||||
# prompts the user to input the price of the burrito, then sets var price to user input
|
||||
price = int(input("Please enter cost of burrito: "))
|
||||
# set var taxRate to 0.095
|
||||
taxRate = 0.095
|
||||
# set var tax to 0
|
||||
tax = 0
|
||||
# set var tax to var price multiplied by taxRate
|
||||
tax = price * taxRate
|
||||
# prints str "The tax is:" followed by the value of var tax
|
||||
print("The tax is:", tax)
|
||||
|
||||
# Part 4
|
||||
|
||||
# prompts the user to enter a integer, and stores input to var number
|
||||
number = int(input("Please input a number: "))
|
||||
# print str "the number you entered is", followed by var number
|
||||
print("The number you entered is:", number)
|
||||
# print str "Your number in binary is:", convert value of var number to binary and output it
|
||||
print("Your number in binary is:", bin(number))
|
||||
# print str "Your number in hexadecimal is:", convert value of var number to hexadecimal and output it
|
||||
print("Your number in hexadecimal is:", hex(number))
|
||||
Reference in New Issue
Block a user