#nested_loop_example_1 :
""" To print all rows and columns equals with star pattren
i is row and j is column"""
#method_1
for i in range(1,6):
for j in range(1,6):
print("*",end=" ")
print()
print()
#method_2
for i in range(5):
print("* "*5)
""" To print all rows and columns equals with star pattren
i is row and j is column"""
#method_1
for i in range(1,6):
for j in range(1,6):
print("*",end=" ")
print()
print()
#method_2
for i in range(5):
print("* "*5)
#nested_loop_example_2 :
""" To print all rows and columns + 1 with star pattren
#Right half pyramid
i is row and j is column"""
#method_1
for i in range(0,6):
for j in range(i+1):
print("*",end=" ")
print()
print()
#metgod_2
for i in range(6):
for j in range(i+1):
print("*",end=" ")
print()
print()
#method_3
for i in range(6):
print("* "*(i+1))
print()
#method_4
def pattern(n):
k = 2 * n - 2
for i in range(0, n):
for j in range(0, k):
print(end="")
k = k - 2
for j in range(0, i + 1):
print("* ", end="")
print(" ")
pattern(6)
print()
""" To print all rows and columns + 1 with star pattren
#Right half pyramid
i is row and j is column"""
#method_1
for i in range(0,6):
for j in range(i+1):
print("*",end=" ")
print()
print()
#metgod_2
for i in range(6):
for j in range(i+1):
print("*",end=" ")
print()
print()
#method_3
for i in range(6):
print("* "*(i+1))
print()
#method_4
def pattern(n):
k = 2 * n - 2
for i in range(0, n):
for j in range(0, k):
print(end="")
k = k - 2
for j in range(0, i + 1):
print("* ", end="")
print(" ")
pattern(6)
print()
#nested_loop_example_3 :
""" To print reverse all columns and rows - 1 with star pattren
i is row and j is column"""
#method_1
#method_2 (shortcut method)
for i in range(5):
print(" "*i,"* "*(5-i))
""" To print reverse all columns and rows - 1 with star pattren
i is row and j is column"""
#method_1
#method_2 (shortcut method)
for i in range(5):
print(" "*i,"* "*(5-i))
#nested_loop_example_4 :
""" To print left half pyramid with star pattren program
i is row and j is column"""
#method_1
#method_2 (shortcut method)
n = int(input("Enter the value: "))
for i in range(n):
print(" "*(n-(i+1)),"* "*(i+1))
""" To print left half pyramid with star pattren program
i is row and j is column"""
#method_1
#method_2 (shortcut method)
n = int(input("Enter the value: "))
for i in range(n):
print(" "*(n-(i+1)),"* "*(i+1))
everyone can respond my post any one reaction or comment of every post
admin of this channel @itsmekriish
admin of this channel @itsmekriish
Python programming codes pinned «everyone can respond my post any one reaction or comment of every post admin of this channel @itsmekriish»
#Create note book with python code
import tkinter as tk
from tkinter import filedialog
class Notepad(tk.Tk):
def init(self, *args, **kwargs):
tk.Tk.init(self, *args, **kwargs)
# Set the title for the notepad
self.title("Notepad")
# Create a text widget
self.text = tk.Text(self, wrap="word")
self.text.pack(side="top", fill="both", expand=True)
# Create a menu bar
self.menu = tk.Menu(self)
self.config(menu=self.menu)
# Create a file menu
file_menu = tk.Menu(self.menu)
self.menu.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="New", command=self.new_file)
file_menu.add_command(label="Open", command=self.open_file)
file_menu.add_command(label="Save", command=self.save_file)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=self.quit)
# Create an edit menu
edit_menu = tk.Menu(self.menu)
self.menu.add_cascade(label="Edit", menu=edit_menu)
edit_menu.add_command(label="Cut", command=self.cut)
edit_menu.add_command(label="Copy", command=self.copy)
edit_menu.add_command(label="Paste", command=self.paste)
def new_file(self):
self.text.delete("1.0", "end")
self.title("Notepad")
def open_file(self):
file = filedialog.askopenfile(parent=self, mode="rb", title="Open a file")
if file:
contents = file.read()
self.text.delete("1.0", "end")
self.text.insert("1.0", contents)
file.close()
self.title(file.name + " - Notepad")
def save_file(self):
file = filedialog.asksaveasfile(mode="w", defaultextension=".txt", filetypes=[("Text Documents", "*.txt"), ("All Files", "*.*")])
if file:
contents = self.text.get("1.0", "end")
file.write(contents)
file.close()
self.title(file.name + " - Notepad")
def cut(self):
self.text.event_generate("<<Cut>>")
def copy(self):
self.text.event_generate("<<Copy>>")
def paste(self):
self.text.event_generate("<<Paste>>")
if name == "main":
notepad = Notepad()
notepad.mainloop()
import tkinter as tk
from tkinter import filedialog
class Notepad(tk.Tk):
def init(self, *args, **kwargs):
tk.Tk.init(self, *args, **kwargs)
# Set the title for the notepad
self.title("Notepad")
# Create a text widget
self.text = tk.Text(self, wrap="word")
self.text.pack(side="top", fill="both", expand=True)
# Create a menu bar
self.menu = tk.Menu(self)
self.config(menu=self.menu)
# Create a file menu
file_menu = tk.Menu(self.menu)
self.menu.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="New", command=self.new_file)
file_menu.add_command(label="Open", command=self.open_file)
file_menu.add_command(label="Save", command=self.save_file)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=self.quit)
# Create an edit menu
edit_menu = tk.Menu(self.menu)
self.menu.add_cascade(label="Edit", menu=edit_menu)
edit_menu.add_command(label="Cut", command=self.cut)
edit_menu.add_command(label="Copy", command=self.copy)
edit_menu.add_command(label="Paste", command=self.paste)
def new_file(self):
self.text.delete("1.0", "end")
self.title("Notepad")
def open_file(self):
file = filedialog.askopenfile(parent=self, mode="rb", title="Open a file")
if file:
contents = file.read()
self.text.delete("1.0", "end")
self.text.insert("1.0", contents)
file.close()
self.title(file.name + " - Notepad")
def save_file(self):
file = filedialog.asksaveasfile(mode="w", defaultextension=".txt", filetypes=[("Text Documents", "*.txt"), ("All Files", "*.*")])
if file:
contents = self.text.get("1.0", "end")
file.write(contents)
file.close()
self.title(file.name + " - Notepad")
def cut(self):
self.text.event_generate("<<Cut>>")
def copy(self):
self.text.event_generate("<<Copy>>")
def paste(self):
self.text.event_generate("<<Paste>>")
if name == "main":
notepad = Notepad()
notepad.mainloop()
def myfunc(num):
if num%2==0:
return True else: return False print(myfunc(4))
if num%2==0:
return True else: return False print(myfunc(4))
Anonymous Quiz
29%
2
57%
True
0%
False
14%
Error
mimo app coding 😊 fun 🎯game join and let's friendly
https://getmimo.com/invite/erhmjm
https://getmimo.com/invite/erhmjm
App Store
Mimo: Learn Coding/Programming
Learning to code has never been so easy!
Advance your career, build apps and websites, or even become a developer. Mimo makes learning to code and diving into computer science as intuitive and easy as possible so that everyone can learn to code - the skill…
Advance your career, build apps and websites, or even become a developer. Mimo makes learning to code and diving into computer science as intuitive and easy as possible so that everyone can learn to code - the skill…
Join me on Sololearn — the fun, free way to get tech skills in just 5 mins a day!
https://sololearn.onelink.me/MfgO/p6s69yq0
https://sololearn.onelink.me/MfgO/p6s69yq0
App Store
Sololearn: Learn to Code Apps
Sololearn has the world's largest collection of FREE programming courses to learn how to code. Learn Python, C++, JavaScript, Java, jQuery, machine learning, data science, and more. You receive a certificate for each course that you complete. Choose from…