75 lines
1.1 KiB
Python
75 lines
1.1 KiB
Python
# %%
|
|
## Task 1
|
|
print("A sentence.")
|
|
lname = input("Please enter your last name: ")
|
|
id = input("Please enter your student id: ")
|
|
print(id, lname,sep=";")
|
|
|
|
# %%
|
|
## Task 2
|
|
# 1(a) type int
|
|
# 1(b) type string
|
|
# 1(c) type string
|
|
# 1(d) type int
|
|
|
|
# 2(a) type constant int
|
|
# 2(b) type string
|
|
# 2(c) type int
|
|
# 2(d) type float
|
|
# 2(e) type boolean
|
|
# 2(f) type float
|
|
|
|
# BONUS: 1(a) is most likely type constant int
|
|
|
|
# %%
|
|
## Task 3
|
|
# data1 - type float, 99.9
|
|
# data2 - type integer, 99
|
|
# data3 - type string, "99"
|
|
# data4 - type boolean, True
|
|
# data5 - type float, 0.9
|
|
# data6 - Syntax Error
|
|
|
|
# %%
|
|
## Task 4
|
|
# 1. x=0.5
|
|
# 2. x=0.5
|
|
# 3. x=0.0
|
|
# 4. x=0.25
|
|
# 5. x=110
|
|
# 5. x=1
|
|
# 7. x=0
|
|
# 8. x=.20
|
|
x = 1 / 2
|
|
print(x)
|
|
x = 1 / 2.0
|
|
print(x)
|
|
x = 1 // 2
|
|
print(x)
|
|
x = 1 / 2 / 2
|
|
print(x)
|
|
x = 100 * 1.1
|
|
print(x)
|
|
x = 3 % 2
|
|
print(x)
|
|
x = 6 % 3
|
|
print(x)
|
|
x = 25 ** 0.5
|
|
print(x)
|
|
|
|
# %%
|
|
## Task 5
|
|
# Task 5.1
|
|
alpha = 5
|
|
# Task 5.2
|
|
beta = alpha - 1.25
|
|
# Task 5.3
|
|
gamma = alpha % 2
|
|
# Task 5.4
|
|
delta = alpha ** 4
|
|
# Task 5.5
|
|
epsilon = 9 // 2
|
|
# Task 5.6
|
|
alpha = alpha + 1
|
|
# Task 5.7
|
|
print(alpha, beta, gamma, delta, epsilon) |