-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw11.py
More file actions
36 lines (26 loc) · 831 Bytes
/
Copy pathhw11.py
File metadata and controls
36 lines (26 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#Write a for loop that prints all multiples of 3 between 1 and 30.
for i in range(1,31):
print(f"3X{i}={3*i}") # prints 3 tables
#Write a program using a for loop that calculates the sum of numbers from 1 to 10.
sum=0
for i in range(1,11): #from 1 to 10
sum+=i
print("sum=",sum)
#Write a program that takes your name as input and prints each letter of your name using a for loop.
name=input("enter your name:")
for letter in name:
print(letter)
#Write a program that counts how many vowels are in a given string using a for loop.
text = input("enter a string:")
count = 0
for ch in text:
if ch.lower() in "aeiou":
count += 1
print("Number of vowels =", count)
vowels="aeiou"
s="i am a student"
count=0
for letter in s:
if letter in vowels:
count+=1
print(count)