-
Notifications
You must be signed in to change notification settings - Fork 0
/
forLoopProgramming.py
125 lines (124 loc) · 3.16 KB
/
forLoopProgramming.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
"""#sum of first numbers
no=1
total=0
for no in range(11):
total=total+no
print("First n numbers values is : ",total)
#sum of n numbers in user input
total=0
number=int(input("Enter a any number : "))
for i in range(number+1):
total+=i
print("First n numbers values is : ",total)
#sum of range of numbers
total=0
for no in range(5,20):
total+=no
print("Total a range of numbers 5 to 20 is : ",total)
#sum of range of numbers
total=0
firstNumber=int(input("Enter a first number : "))
secondNumber=int(input("Enter a second number : "))
for no in range(firstNumber,secondNumber+1):
total+=no
print("Total a range of numbers",firstNumber," to", secondNumber," is : ",total)
#sum of number using step up
total=0
for no in range(5,20,2):
total+=no
print("Total a range of numbers 5 to 20 with step 2 is : ",total)
#print odd number only
print("Odd Numbers Only : ")
for i in range(101):
if (i%2!=0):
print(i,end=" ")
i+=1
print()
#print even number only
print("Even Numbers Only : ")
for i in range(101):
if (i%2==0):
print(i,end=" ")
i+=1
print()
# print multiples of 3 only
print("Multiples of 3 Only : ")
for i in range(1,101):
if (i % 3== 0):
print(i, end=" ")
i += 1
print()
# print multiples of 3 only using step operation
print("Multiples of 3 Only using step operation : ")
for i in range(3,101,3):
print(i, end=" ")
print()
#Palindrome
word="madams"
word2=word[::-1]
if word==word2:
print("The given word",word,"is palindrome")
else:
print("The given word",word,"is Not palindrome")"""
# #sentence
# sentence ="All is Well"
# for letter in sentence:
# print(letter,end=" ")
# print()
# #sentence find vowls
# sentence ="All is Well"
# for letter in sentence:
# if letter in ['a','e','i','o','u','A','E','I','O','U']:
# print(letter,end=" ")
# print()
# #find the no. of words
# sentence="My name is Arunkumar"
# count=1
# space=" "
# for letter in sentence:
# if letter in space:
# count+=1
# print("No. of words present is : ",count)
# #find the no. of sentence
# sentence="My name is Arunkumar. I completed BE. I am from Kumbakonam."
# count=0
# for letter in sentence:
# if letter ==".":
# count+=1
# print("No. of sentence present is : ",count)
# print()
# #print capital letter using ord()
# for letter in range(ord('A'),ord('Z')+1):
# print(chr(letter),end=" ")
# print()
# # print capital letter using ASCII value
# for letter in range(65, 91):
# print(chr(letter), end=" ")
# print()
# #using pass
# for number in [1]:
# pass
# print("Hello",number)
#program
user=input("Enter your mail id : ")
# i=0
# while i<len(user):
# print(user[i],end=" ")
#ASCII Value
# 65-91 - A-Z
# 97-122 - a-z
# 48-57 - 0-9
length=len(user)
countOfNumbers=0
countOfAlphabet=0
countOfSpecialChar=0
for no in range(length):
if((user[no]>='A'and user[no]<='Z')or(user[no]>='a'and user[no]<='z')):
countOfAlphabet=countOfAlphabet+1
elif (user[no]>='0'and user[no]<='9'):
countOfNumbers=countOfNumbers+1
else:
countOfSpecialChar=countOfSpecialChar+1
print("countAlpha : ",countOfAlphabet)
print("countNum : ",countOfNumbers)
print("countSpecial : ",countOfSpecialChar)