for loopsrange()+, -, *, /, //, **, %int, float, and str types""+, string repetition with *[]len()<, <=, ==, >, >=, !=and, or, and notord() and chr()for i in range(4):
print(i)
print("--")
for x in range(6):
print(x, x**2)
print("done!")
text = "hello!"
for i in range(len(text)):
print("-" + text[i] + "-")
Write a program that asks the user for their name, and then prints their name 20 times.
Given these assignments:
x = 5
y = 13
S = "we love computer science"
Show the value and type of each expression below:
x < 10 and y < 10
x < 10 or y < 10
x < 10 and x > 0
x > 10 or x < 0
(5/x) > 7.0
len(S) >= 10
S[0] < S[1]
x = 3
print("%d %d" % (0,x))
for i in range(5):
if x % 2 == 0:
x = x / 2
else:
x = (3*x+1)/2
print("%d %d" % (i,x))
Enter number of grades to average: 5
Enter grade: 96
Enter grade: 86
Enter grade: 76
Enter grade: 66
Enter grade: 56
Average is: 76.0