print (“choose a no\n”)
one = int(input())
print(“select 1 or 0\n”)
two = int(input())
newin = bool(two)
if newin == True :
for i in range (1,one+1):
for j in range(1,i+1):
print(““,end = ” “) print() if newin == False : for i in range (one,0,-1): for j in range(1,i+1): print(““, end = ” “)
print()
Author Archives: fahad Hussain
Number guessing game it was hard 22/8/21
n = 18
print(“please guess the no in 9 tries”)
no_of_guess = 1
while(no_of_guess < 10):
guess = int(input(“please guess the no\n”))
if guess <= 16 :
print(“your guess is wrong please in increase the no”)
elif guess >= 20 :
print(“your guess is wrong please decrease the no”)
elif guess == 17 :
print(“you are close increase the no a bit”)
elif guess == 19 :
print(“you are close decrease the no a bit”)
# elif no_of_tries == 0:
# print (“game over”)
# break
else :
print(“you won you choose the right no in”,no_of_guess,”tries”)
break
no_of_tries= (9 – no_of_guess)
no_of_guess = no_of_guess + 1
print(no_of_tries,”tries left”)
if no_of_tries == 0:
print(“game over”)
#Here i made a number guessing game uzing simple if esle statement s and while loop
Students attendance percentage calculator 20/8/21
students = {“fahad” : 15 ,”arshu” : 10, “anzar” : 20 , “moiz” : 30}
name = input(“what is your name”)
name1 = (students[name])
percent = (name1/30*100)
if name1 < 15 :
print(“very bad attendence this will cause issues”,”your attendance percentage is”,(percent))
else :
print(“you have good attendence no issues”,”your attendance percentage is”,(percent))
#here i have made a student attendance percentage calculator as well as review from data given in dictionary form
#here it asks you your name and calculates the percentage of you attendance in a month of 30 with the
#help of percent formula and IF AND ELSE statements
first project Code for dictionary small 20/8/21
dict1 = {“knife” : “a sharp cutting tool”, “TV” : “Television”, “legs”: “body part”, “rain”:”water form the clouds”}
pick1 = input(“pick a word:”)
print(dict1[pick1])
#Here first i created a dictionary and #then named dict1 plus i named pick1 #the input function
#In the last i printed from the dictionary dict1 it searched pick1 (key ) and gave his value