PYTHON_LEARNING_DUMP
a=10
count=0
while count<a :
count = count+1
print (count)
--------------------------------------------------------------------------------------------------
#count total number of spaces, vowels and consonants in the given string
length= len(string)
print(f"total length of given string is: {length}")
#number of vovel
vowel="aeiou"
vow_count=0
cons = "bcdfghjklmnpqrstvwxyz"
cons_count=0
space=" "
space_count=0
string=string.lower()
for i in string:
if i in cons:
cons_count = cons_count+1
elif i in vowel:
vow_count = vow_count+1
elif i in space:
space_count = space_count+1
print(f"Total number of spaces in the given string is: {space_count}")
print(f"Total number of consonants in the given string is: {cons_count}")
print(f"Total number of vowels in the given string is: {vow_count}")
----------------------------------------------------------------------------------------------------------------------
"""
#Create a list of menu items of 10
#Build a logic to loop through one by one and give me the min length item name
menu = ['Samosa', 'Pizza', 'Idli', 'Salad', 'Dosa', 'Ice Cream', 'Pasta', 'Sandwich', 'Noodles', 'Manchurian']
print(f"Menu with 10 items:\n{menu}")
min_len = len(menu[0])
min_len_items = []
for item in menu:
item_len = len(item)
if item_len < min_len:
min_len = item_len
min_len_items = [item]
elif item_len == min_len:
min_len_items.append(item)
print(f"Items with the minimum length: {min_len_items}")
----------------------------------------------------------------------------------------------------------------------
'''
Create a list of odd numbers (at least 25) and find all those numbers which are divisible by other than 1 and on its own
(example 5 vs 9)
'''
odd_num = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51]
num = []
for i in odd_num:
is_composite = False
for j in range(2, i):
if i % j == 0:
is_composite = True
break
if is_composite:
num.append(i)
print(f"Composite numbers:{num}")
#output: Composite numbers:[9, 15, 21, 25, 27, 33, 35, 39, 45, 49, 51]
----------------------------------------------------------------------------------------------------------------------
'''
Student_marks = [[‘Raj’, 850],[‘Ram’, 999],[‘Jay’,756],[‘Radha’,923],[‘Vaidhi’,990]]
Add grace marks of 30 for each students
Now, give me the list of students with marks greater than 850
'''
student_marks = [['Raj', 850],['Ram',999],['Jay',756],['Radha',923],['Vaidhi',990]]
print(f"Initial students marks: {student_marks}")
new_marks = list(map(lambda marks : marks[1]+30 , student_marks))
print (f"Students marks after adding grace marks, 30 : {new_marks}")
f_marks = list(filter(lambda marks : marks[1]>850 , student_marks))
print (f"Students with marks more than 850: {f_marks}")
"""
OUTPUT:
Initial students marks: [['Raj', 850], ['Ram', 999], ['Jay', 756], ['Radha', 923], ['Vaidhi', 990]]
Students marks after adding grace marks, 30 : [880, 1029, 786, 953, 1020]
Students with marks more than 850: [['Ram', 999], ['Radha', 923], ['Vaidhi', 990]]
"""
---------------------------------------------------------------------------------------------------------------------
Given a year, determine whether it is a leap year. If it is a leap year, return the Boolean True
, otherwise return False
.
The included code stub will read an integer, , from STDIN.
Without using any string methods, try to print the following:
Note that "" represents the consecutive values in between.
Example
Print the string : 12345
if __name__ == '__main__':
" "
(space) delimiter and join using a -
hyphen.firstname
lastname
! You just delved into python.
Comments
Post a Comment